-
Notifications
You must be signed in to change notification settings - Fork 363
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
[SDK-1649] Fix issue where cache was missed when scope parameter was provided #461
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -512,4 +512,33 @@ describe('Auth0Client', () => { | |
value: originalUserAgent | ||
}); | ||
}); | ||
|
||
it('uses the cache for multiple token requests with audience and scope', async () => { | ||
const auth0 = setup(); | ||
await login(auth0); | ||
jest.spyOn(<any>utils, 'runIframe').mockResolvedValue({ | ||
access_token: 'my_access_token', | ||
state: 'MTIz' | ||
}); | ||
mockFetch.mockResolvedValue( | ||
fetchResponse(true, { | ||
id_token: 'my_id_token', | ||
refresh_token: 'my_refresh_token', | ||
access_token: 'my_access_token', | ||
expires_in: 86400 | ||
}) | ||
); | ||
let access_token = await auth0.getTokenSilently({ | ||
audience: 'foo', | ||
scope: 'bar' | ||
}); | ||
expect(access_token).toEqual('my_access_token'); | ||
expect(utils.runIframe).toHaveBeenCalledTimes(1); | ||
access_token = await auth0.getTokenSilently({ | ||
audience: 'foo', | ||
scope: 'bar' | ||
}); | ||
expect(access_token).toEqual('my_access_token'); | ||
expect(utils.runIframe).toHaveBeenCalledTimes(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it would better here to reset the The way the test reads right now at first glance is that we're expecting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah 👍 good idea |
||
}); | ||
}); |
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.
Just a general question; do we want to migrate tests out of
index.test.ts
into this file? I'm conscious that we're starting to develop a set of tests across two places for the same functions.Perhaps we should dedicate some effort to unifying the tests somewhere to make them more discoverable.
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.
Agreed