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:
Patrik Oldsberg
2023-10-23 17:37:18 +02:00
parent 89d13e5618
commit 56baf8763a
2 changed files with 8 additions and 8 deletions
@@ -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',
);
});
});
@@ -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 () => {