diff --git a/src/app/shared/guards/application-role-guard.service.spec.ts b/src/app/shared/guards/application-role-guard.service.spec.ts index 556ec8260c566309b1fa0652d53f8c7eeabf539b..ee1bb891429a5f81adbaa21980c317d8ec564e4d 100644 --- a/src/app/shared/guards/application-role-guard.service.spec.ts +++ b/src/app/shared/guards/application-role-guard.service.spec.ts @@ -12,7 +12,7 @@ import {ApplicationRoleGuardService} from "@app/shared/guards/application-role-g import {JwtTokenHelper} from "@app/shared/helpers/jwt-token.helper"; import {DlcmData} from "@app/shared/models/dlcm-route.model"; import {Token} from "@app/shared/models/token.model"; -import {LoginSuccess} from "@app/stores/app.action"; +import {AppAction} from "@app/stores/app.action"; import { AppState, AppStateModel, @@ -77,7 +77,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.user]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -91,7 +91,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.admin]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -105,7 +105,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.admin]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -119,7 +119,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.admin]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -133,7 +133,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.user, ApplicationRoleEnum.admin]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -147,7 +147,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.user]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -161,7 +161,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.user, ApplicationRoleEnum.admin]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -175,7 +175,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = [ApplicationRoleEnum.user, ApplicationRoleEnum.admin, ApplicationRoleEnum.root]; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -189,7 +189,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = null; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -203,7 +203,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = null; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -217,7 +217,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = null; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -231,7 +231,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = []; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -245,7 +245,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = null; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -259,7 +259,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = []; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); @@ -273,7 +273,7 @@ describe("ApplicationRoleGuardService", () => { const simulatingCurrentUserRole = []; spyOn(JwtTokenHelper, "decodeToken").and.returnValue({authorities: simulatingCurrentUserRole} as Token); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state: AppStateModel = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); expect(state.userRoles).toEqual(simulatingCurrentUserRole); diff --git a/src/app/shared/guards/auth-guard.service.spec.ts b/src/app/shared/guards/auth-guard.service.spec.ts index 5c290ab32f31fa613705d9bfcb718e85a957af00..54c680c5a1bd3739fde4735ac7f958fe212e423f 100644 --- a/src/app/shared/guards/auth-guard.service.spec.ts +++ b/src/app/shared/guards/auth-guard.service.spec.ts @@ -4,10 +4,7 @@ import {TestBed} from "@angular/core/testing"; import {MatSnackBar} from "@angular/material"; import {Router} from "@angular/router"; import {AuthGuardService} from "@app/shared/guards/auth-guard.service"; -import { - LoginFail, - LoginSuccess, -} from "@app/stores/app.action"; +import {AppAction} from "@app/stores/app.action"; import {AppState} from "@app/stores/app.state"; import {AppAuthorizedOrganizationalUnitState} from "@app/stores/authorized-organizational-unit/app-authorized-organizational-unit.state"; import {AppOrganizationalUnitPersonRoleState} from "@app/stores/organizational-unit-person-role/app-organizational-unit-person-role.state"; @@ -67,7 +64,7 @@ describe("AuthGuardService", () => { const service: AuthGuardService = TestBed.get(AuthGuardService); const store: Store = TestBed.get(Store); - await store.dispatch(new LoginSuccess(null)).toPromise(); + await store.dispatch(new AppAction.LoginSuccess(null)).toPromise(); const state = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(true); @@ -78,7 +75,7 @@ describe("AuthGuardService", () => { const service: AuthGuardService = TestBed.get(AuthGuardService); const store: Store = TestBed.get(Store); - await store.dispatch(new LoginFail(null)).toPromise(); + await store.dispatch(new AppAction.LoginFail(null)).toPromise(); const state = store.selectSnapshot(AppState); expect(state.isLoggedIn).toBe(false);