auth-*: test fixes for new CookieScopeManager

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-05-13 14:04:05 +02:00
parent dd99788e6b
commit bdabd9952e
5 changed files with 5 additions and 5 deletions
@@ -72,6 +72,7 @@ describe('authModuleGithubProvider', () => {
expect(decodeOAuthState(startUrl.searchParams.get('state')!)).toEqual({
env: 'development',
nonce: decodeURIComponent(nonceCookie.value),
scope: '',
});
});
});
@@ -67,7 +67,7 @@ describe('authModuleMicrosoftProvider', () => {
expect(startUrl.pathname).toBe('/my-tenant-id/oauth2/v2.0/authorize');
expect(Object.fromEntries(startUrl.searchParams)).toEqual({
response_type: 'code',
scope: 'user.read User.Read.All',
scope: 'User.Read.All',
client_id: 'my-client-id',
redirect_uri: `http://localhost:${server.port()}/api/auth/microsoft/handler/frame`,
state: expect.any(String),
@@ -212,6 +212,7 @@ describe('authModuleOidcProvider', () => {
expect(decodeOAuthState(startUrl.searchParams.get('state')!)).toEqual({
env: 'development',
nonce: decodeURIComponent(nonceCookie.value),
scope: '',
});
});
@@ -21,9 +21,7 @@ import { decodeOAuthState } from '@backstage/plugin-auth-node';
describe('authModuleOktaProvider', () => {
it('should start', async () => {
const defaultScopes = 'openid profile email';
const additionalScopes = 'groups phone';
const combinedScopes = `${defaultScopes} ${additionalScopes}`;
const { server } = await startTestBackend({
features: [
import('@backstage/plugin-auth-backend'),
@@ -68,7 +66,7 @@ describe('authModuleOktaProvider', () => {
expect(startUrl.pathname).toBe('/oauth2/v1/authorize');
expect(Object.fromEntries(startUrl.searchParams)).toEqual({
response_type: 'code',
scope: combinedScopes,
scope: additionalScopes,
client_id: 'my-client-id',
redirect_uri: `http://localhost:${server.port()}/api/auth/okta/handler/frame`,
state: expect.any(String),
@@ -119,7 +119,7 @@ export class CookieScopeManager {
}
const scope = ctx.state.scope;
if (!scope) {
if (scope === undefined) {
throw new AuthenticationError('No scope found in OAuth state');
}