Skip to content
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

Ims maintenance endpoints #1398

Merged
merged 12 commits into from
Jul 3, 2024
20 changes: 10 additions & 10 deletions src/authentication/ldapjwtAuthProvider.test.tsx
MatteoGuarnaccia5 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import mockAxios from 'axios';
import LDAPJWTAuthProvider from './ldapjwtAuthProvider';
import LDAPJWTAuthProvider from './ldapJWTAuthProvider';

describe('ldapJWT auth provider', () => {
let ldapJjwtAuthProvider: LDAPJWTAuthProvider;
describe('LDAP-JWT Auth provider', () => {
let ldapJWTAuthProvider: LDAPJWTAuthProvider;

beforeEach(() => {
ldapJjwtAuthProvider = new LDAPJWTAuthProvider('http://localhost:8000');
ldapJWTAuthProvider = new LDAPJWTAuthProvider('http://localhost:8000');
});

it('should call api to fetch maintenance state', async () => {
Expand All @@ -18,7 +18,7 @@ describe('ldapJWT auth provider', () => {
})
);

await ldapJjwtAuthProvider.fetchMaintenanceState();
await ldapJWTAuthProvider.fetchMaintenanceState();
expect(mockAxios.get).toHaveBeenCalledWith(
'http://localhost:8000/maintenance'
);
Expand All @@ -35,7 +35,7 @@ describe('ldapJWT auth provider', () => {
})
);

await ldapJjwtAuthProvider.fetchScheduledMaintenanceState();
await ldapJWTAuthProvider.fetchScheduledMaintenanceState();
expect(mockAxios.get).toHaveBeenCalledWith(
'http://localhost:8000/scheduled_maintenance'
);
Expand All @@ -50,11 +50,11 @@ describe('ldapJWT auth provider', () => {
})
);

await ldapJjwtAuthProvider.fetchMaintenanceState().catch(() => {
await ldapJWTAuthProvider.fetchMaintenanceState().catch(() => {
// catch error
});

expect(ldapJjwtAuthProvider.isLoggedIn()).toBeFalsy();
expect(ldapJWTAuthProvider.isLoggedIn()).toBeFalsy();
});

it('should log the user out if it fails to fetch scheduled maintenance state', async () => {
Expand All @@ -66,10 +66,10 @@ describe('ldapJWT auth provider', () => {
})
);

await ldapJjwtAuthProvider.fetchScheduledMaintenanceState().catch(() => {
await ldapJWTAuthProvider.fetchScheduledMaintenanceState().catch(() => {
// catch error
});

expect(ldapJjwtAuthProvider.isLoggedIn()).toBeFalsy();
expect(ldapJWTAuthProvider.isLoggedIn()).toBeFalsy();
});
});
7 changes: 7 additions & 0 deletions src/state/reducers/scigateway.reducer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import JWTAuthProvider from '../../authentication/jwtAuthProvider';
import GithubAuthProvider from '../../authentication/githubAuthProvider';
import ICATAuthProvider from '../../authentication/icatAuthProvider';
import NullAuthProvider from '../../authentication/nullAuthProvider';
import LDAPJWTAuthProvider from '../../authentication/ldapJWTAuthProvider';

describe('scigateway reducer', () => {
let state: ScigatewayState;
Expand Down Expand Up @@ -280,6 +281,12 @@ describe('scigateway reducer', () => {
ICATAuthProvider
);

updatedState = ScigatewayReducer(state, loadAuthProvider('ldap-jwt'));

expect(updatedState.authorisation.provider).toBeInstanceOf(
LDAPJWTAuthProvider
);
MatteoGuarnaccia5 marked this conversation as resolved.
Show resolved Hide resolved

updatedState = ScigatewayReducer(state, loadAuthProvider('icat.anon'));

expect(updatedState.authorisation.provider).toBeInstanceOf(
Expand Down
2 changes: 1 addition & 1 deletion src/state/reducers/scigateway.reducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import GithubAuthProvider from '../../authentication/githubAuthProvider';
import NullAuthProvider from '../../authentication/nullAuthProvider';
import { Step } from 'react-joyride';
import ICATAuthProvider from '../../authentication/icatAuthProvider';
import LDAPJWTAuthProvider from '../../authentication/ldapjwtAuthProvider';
import LDAPJWTAuthProvider from '../../authentication/ldapJWTAuthProvider';

export const authState: AuthState = {
failedToLogin: false,
Expand Down
Loading