-
Notifications
You must be signed in to change notification settings - Fork 542
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
Use OAUTH token if set for analytics #2159
Conversation
headers: { | ||
host: 'localhost:12345', | ||
accept: 'application/json', | ||
authorization: 'Bearer oauth-jwt-token', |
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.
We can be less verbose in this test case and just match on the authorization header since that's all we care about.
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.
👍
expect(code).toBe(0); | ||
|
||
const lastRequest = server.popRequest(); | ||
expect(lastRequest).toMatchObject({ |
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.
Could do something like not.toHaveProperty('headers.authorization')
to be less verbose.
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.
👍
src/lib/api-token.ts
Outdated
const oauthToken: string | undefined = getOAuthToken(); | ||
const dockerToken: string | undefined = getDockerToken(); | ||
const apiToken: string | undefined = api(); | ||
return Boolean(oauthToken || dockerToken || apiToken); |
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.
We can inline these variables. I don't think naming them adds much, makes it more noisy (esp. with type annotations). And maybe check for api()
first as it's the most common.
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.
👍
e105239
to
210c44c
Compare
210c44c
to
14a0b76
Compare
What does this PR do?
Update Analytics to use the OAUTH token if it is set.