core-app-api: test fixes for including default scopes in initial refresh
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -44,9 +44,7 @@ describe('MicrosoftAuth', () => {
|
||||
return res(
|
||||
ctx.json({
|
||||
providerInfo: {
|
||||
accessToken: scopeParam
|
||||
? 'tokenForOtherResource'
|
||||
: 'tokenForGrantScopes',
|
||||
accessToken: `token:${scopeParam}`,
|
||||
scope: scopeParam || 'grant-resource/scope',
|
||||
},
|
||||
}),
|
||||
@@ -59,7 +57,9 @@ describe('MicrosoftAuth', () => {
|
||||
it('gets access token with requested scopes for grant', async () => {
|
||||
const accessToken = await microsoftAuth.getAccessToken();
|
||||
|
||||
expect(accessToken).toEqual('tokenForGrantScopes');
|
||||
expect(accessToken).toEqual(
|
||||
'token:openid offline_access profile email User.Read',
|
||||
);
|
||||
});
|
||||
|
||||
it('gets access token for other consented scopes besides those directly granted', async () => {
|
||||
@@ -67,7 +67,7 @@ describe('MicrosoftAuth', () => {
|
||||
'azure-resource/scope',
|
||||
);
|
||||
|
||||
expect(accessToken).toEqual('tokenForOtherResource');
|
||||
expect(accessToken).toEqual('token:azure-resource/scope offline_access');
|
||||
});
|
||||
|
||||
it('fails when requesting scopes for multiple resources at once', async () => {
|
||||
@@ -86,7 +86,7 @@ describe('MicrosoftAuth', () => {
|
||||
);
|
||||
|
||||
await expect(accessTokenPromise).resolves.toEqual(
|
||||
'tokenForOtherResource',
|
||||
'token:same-resource/one-scope same-resource/other-scope offline_access',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
await manager.getSession({});
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(refreshSession).toHaveBeenCalledWith(undefined);
|
||||
expect(refreshSession).toHaveBeenCalledWith(new Set());
|
||||
expect(stateSubscriber.mock.calls).toEqual([
|
||||
[SessionState.SignedOut],
|
||||
[SessionState.SignedIn],
|
||||
@@ -134,7 +134,7 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
|
||||
expect(await manager.getSession({ optional: true })).toBe(undefined);
|
||||
expect(createSession).toHaveBeenCalledTimes(0);
|
||||
expect(refreshSession).toHaveBeenCalledWith(undefined);
|
||||
expect(refreshSession).toHaveBeenCalledWith(new Set());
|
||||
});
|
||||
|
||||
it('should forward option to instantly show auth popup and not attempt refresh', async () => {
|
||||
|
||||
Reference in New Issue
Block a user