Skip to content
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

Merged
merged 3 commits into from
Mar 30, 2023

Conversation

JohnGale87
Copy link
Contributor

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:

  • [ x ] Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • [ x ] Ensure the tests and linter pass
  • [ x ] Code coverage does not decrease (if any source code was changed)
  • [ N/A ] Appropriate docs were updated (if necessary)

Fixes #2169 🦕

@JohnGale87 JohnGale87 requested review from a team as code owners March 27, 2023 12:12
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 27, 2023
@conventional-commit-lint-gcf
Copy link

conventional-commit-lint-gcf bot commented Mar 27, 2023

🤖 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 automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Mar 27, 2023
@JohnGale87 JohnGale87 changed the title fix v4 Signing Errors with exactly 7 day expiry fix: v4 Signing Errors with exactly 7 day expiry Mar 27, 2023
@@ -573,6 +573,52 @@ describe('signer', () => {
);
});

it('should not throw with expiration of exactly 7 days', async () => {
Copy link
Contributor Author

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?

Copy link
Contributor

@ddelgrosso1 ddelgrosso1 Mar 29, 2023

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');
Copy link
Contributor Author

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.

@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 28, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 28, 2023
@ddelgrosso1 ddelgrosso1 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 28, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 28, 2023
test/signer.ts Outdated
const SEVEN_DAYS_IN_MS = SEVEN_DAYS_IN_SECONDS * 1000;
await assert.doesNotReject(
async () => {
await file.getSignedUrl({
Copy link
Contributor

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:

signer.getSignedUrl({

Copy link
Contributor Author

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.

@ddelgrosso1
Copy link
Contributor

Appreciate the contribution @JohnGale87!

@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 30, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 30, 2023
@ddelgrosso1 ddelgrosso1 added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 30, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 30, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 30, 2023
@ddelgrosso1 ddelgrosso1 merged commit f930998 into googleapis:main Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4 Signing Errors with exactly 7 day expiry
3 participants