-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: v4 Signing Errors with exactly 7 day expiry #2170
Conversation
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
… and is thrown. added tests to replicate.
@@ -573,6 +573,52 @@ describe('signer', () => { | |||
); | |||
}); | |||
|
|||
it('should not throw with expiration of exactly 7 days', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if this should be a unittest or a system test so I added it as both.
This unittest tests the signer by using the file object so isn't really a "unit" test however this was the closest thing to my real world problem that I could think of testing.
N.B. Even with the private key generation, mocha does not flag this unittest as a long running run so I figured it was ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much appreciated adding both. We have the timeout set as 10s for these tests.
@@ -56,7 +56,7 @@ describe('signer', () => { | |||
let bucket: BucketI; | |||
let file: FileI; | |||
|
|||
const NOW = new Date('2019-03-18T00:00:00Z'); | |||
const NOW = new Date('2019-03-18T00:00:00.999Z'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only values >= 500 trigger the error, if the ms date part is in the range 0 - 499 then Math.round
functions correctly.
test/signer.ts
Outdated
const SEVEN_DAYS_IN_MS = SEVEN_DAYS_IN_SECONDS * 1000; | ||
await assert.doesNotReject( | ||
async () => { | ||
await file.getSignedUrl({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be accomplished without the need of pulling in file
. For example:
Line 208 in 2c967f6
signer.getSignedUrl({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes agreed. Please see latest commit.
Appreciate the contribution @JohnGale87! |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #2169 🦕