Skip to content

Commit

Permalink
update tests for new login flow
Browse files Browse the repository at this point in the history
  • Loading branch information
skovati committed Dec 12, 2023
1 parent 5825847 commit 9a94b89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
3 changes: 2 additions & 1 deletion docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ services:
container_name: aerie_gateway
depends_on: ['postgres']
environment:
AUTH_TYPE: none
AUTH_TYPE: default
AUTH_UI_URL: 'http://localhost/login'
GQL_API_URL: http://localhost:8080/v1/graphql
HASURA_GRAPHQL_JWT_SECRET: '${HASURA_GRAPHQL_JWT_SECRET}'
LOG_FILE: console
Expand Down
34 changes: 0 additions & 34 deletions src/utilities/login.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { env } from '$env/dynamic/public';
import { afterEach, describe, expect, test, vi } from 'vitest';
import { shouldRedirectToLogin } from './login';
import { ADMIN_ROLE } from './permissions';
Expand All @@ -16,8 +15,6 @@ describe('login util functions', () => {

describe('shouldRedirectToLogin', () => {
test('Should determine if the route should redirect to the login page when login is enabled', () => {
vi.mocked(env).PUBLIC_LOGIN_PAGE = 'enabled';

expect(shouldRedirectToLogin(null)).toEqual(true);
expect(
shouldRedirectToLogin({
Expand Down Expand Up @@ -45,36 +42,5 @@ describe('login util functions', () => {
}),
).toEqual(false);
});

test('Should not redirect if login is disabled', () => {
vi.mocked(env).PUBLIC_LOGIN_PAGE = 'disabled';

expect(shouldRedirectToLogin(null)).toEqual(false);
expect(
shouldRedirectToLogin({
activeRole: 'user',
allowedRoles: [ADMIN_ROLE, 'user'],
defaultRole: 'user',
id: 'foo',
permissibleQueries: {},
rolePermissions: {},
token: 'foo',
}),
).toEqual(false);

expect(
shouldRedirectToLogin({
activeRole: 'user',
allowedRoles: [ADMIN_ROLE, 'user'],
defaultRole: 'user',
id: 'foo',
permissibleQueries: {
constraints: true,
},
rolePermissions: {},
token: 'foo',
}),
).toEqual(false);
});
});
});

0 comments on commit 9a94b89

Please sign in to comment.