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: call addSharedMetadataHeaders even when token has not expired #1116

Merged
merged 5 commits into from Jan 27, 2021

Conversation

hideto0710
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:

  • 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
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1114 🦕


npm test -- -g "getRequestHeaders should populate x-goog-user-project"

before

  refresh
    ✓ getRequestHeaders should populate x-goog-user-project header if quota_project_id present
    1) getRequestHeaders should populate x-goog-user-project header if quota_project_id present and token has not expired


  1 passing (43ms)
  1 failing

  1) refresh
       getRequestHeaders should populate x-goog-user-project header if quota_project_id present and token has not expired:
     AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ undefined
- 'my-quota-project'

after

  refresh
    ✓ getRequestHeaders should populate x-goog-user-project header if quota_project_id present
    ✓ getRequestHeaders should populate x-goog-user-project header if quota_project_id present and token has not expired

@hideto0710 hideto0710 requested a review from a team as a code owner January 17, 2021 00:09
@google-cla
Copy link

google-cla bot commented Jan 17, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no This human has *not* signed the Contributor License Agreement. label Jan 17, 2021
@codecov
Copy link

codecov bot commented Jan 17, 2021

Codecov Report

Merging #1116 (2b4714e) into master (8786d15) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1116   +/-   ##
=======================================
  Coverage   91.65%   91.65%           
=======================================
  Files          21       21           
  Lines        4157     4157           
  Branches      464      430   -34     
=======================================
  Hits         3810     3810           
  Misses        347      347           
Impacted Files Coverage Δ
src/auth/oauth2client.ts 96.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8786d15...2b4714e. Read the comment docs.

@hideto0710
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jan 17, 2021
@hideto0710 hideto0710 changed the title call addSharedMetadataHeaders even when token has not expired fix: call addSharedMetadataHeaders even when token has not expired Jan 17, 2021
@bcoe
Copy link
Contributor

bcoe commented Jan 21, 2021

@hideto0710 good catch 👍 (CC: @sofisl). If I'm following correctly, the quota project was properly populated up until the token refreshed?

I understand, the problem was specifically when grabbing headers and happened prior to expiry 👍

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind adding the additional test? thank you very much for the contribution 🎉

@@ -152,4 +152,22 @@ describe('refresh', () => {
assert.strictEqual(headers['x-goog-user-project'], 'my-quota-project');
req.done();
});

it('getRequestHeaders should populate x-goog-user-project header if quota_project_id present and token has not expired', async () => {
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 we should also add a test that makes sure you get the appropriate header populated after the expiry?

(sorry for the slow review, we'll work on getting this out the door quickly.).

@bcoe bcoe added automerge: secure kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jan 26, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 27, 2021
@bcoe bcoe merged commit aad043d into googleapis:master Jan 27, 2021
@bcoe
Copy link
Contributor

bcoe commented Jan 27, 2021

@hideto0710 thank you very much for the contribution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge: secure cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x-goog-user-project header has gone in second request
4 participants