Skip to content

Commit f3982cb

Browse files
committed
[DURACOM-327] Remove reference to AppState
1 parent df8f915 commit f3982cb

10 files changed

Lines changed: 41 additions & 33 deletions

src/app/core/auth/auth-blocking.guard.spec.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ import {
1212
} from '@ngrx/store/testing';
1313
import { cold } from 'jasmine-marbles';
1414

15-
import {
16-
AppState,
17-
storeModuleConfig,
18-
} from '../../app.reducer';
15+
import { CoreState } from '../core-state.model';
1916
import { authReducer } from './auth.reducer';
2017
import { authBlockingGuard } from './auth-blocking.guard';
2118

2219
describe('authBlockingGuard', () => {
2320
let guard: any;
2421
let initialState;
25-
let store: Store<AppState>;
26-
let mockStore: MockStore<AppState>;
22+
let store: Store<CoreState>;
23+
let mockStore: MockStore<CoreState>;
2724

2825
initialState = {
2926
core: {
@@ -37,10 +34,17 @@ describe('authBlockingGuard', () => {
3734
},
3835
};
3936

37+
const mockStoreModuleConfig = {
38+
runtimeChecks: {
39+
strictStateImmutability: true,
40+
strictActionImmutability: true,
41+
},
42+
};
43+
4044
beforeEach(waitForAsync(() => {
4145
TestBed.configureTestingModule({
4246
imports: [
43-
StoreModule.forRoot(authReducer, storeModuleConfig),
47+
StoreModule.forRoot(authReducer, mockStoreModuleConfig),
4448
],
4549
providers: [
4650
provideMockStore({ initialState }),
@@ -51,7 +55,7 @@ describe('authBlockingGuard', () => {
5155

5256
beforeEach(() => {
5357
store = TestBed.inject(Store);
54-
mockStore = store as MockStore<AppState>;
58+
mockStore = store as MockStore<CoreState>;
5559
guard = authBlockingGuard;
5660
});
5761

src/app/core/auth/auth-blocking.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
take,
1717
} from 'rxjs/operators';
1818

19-
import { AppState } from '../../app.reducer';
19+
import { CoreState } from '../core-state.model';
2020
import { isAuthenticationBlocking } from './selectors';
2121

2222
/**
@@ -27,7 +27,7 @@ import { isAuthenticationBlocking } from './selectors';
2727
export const authBlockingGuard: CanActivateFn = (
2828
route: ActivatedRouteSnapshot,
2929
state: RouterStateSnapshot,
30-
store: Store<AppState> = inject(Store<AppState>),
30+
store: Store<CoreState> = inject(Store<CoreState>),
3131
): Observable<boolean> => {
3232
return store.pipe(select(isAuthenticationBlocking)).pipe(
3333
map((isBlocking: boolean) => isBlocking === false),

src/app/core/auth/auth-methods.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import uniqBy from 'lodash/uniqBy';
77
import { Observable } from 'rxjs';
88
import { map } from 'rxjs/operators';
99

10-
import { AppState } from '../../app.reducer';
1110
import { AuthMethodTypeComponent } from '../../shared/log-in/methods/auth-methods.type';
1211
import { rendersAuthMethodType } from '../../shared/log-in/methods/log-in.methods-decorator.utils';
12+
import { CoreState } from '../core-state.model';
1313
import { AuthMethod } from './models/auth.method';
1414
import { AuthMethodType } from './models/auth.method-type';
1515
import { getAuthenticationMethods } from './selectors';
@@ -22,7 +22,7 @@ import { getAuthenticationMethods } from './selectors';
2222
* Provides methods to retrieve and process authentication methods from the application store.
2323
*/
2424
export class AuthMethodsService {
25-
constructor(protected store: Store<AppState>) {
25+
constructor(protected store: Store<CoreState>) {
2626
}
2727

2828
/**

src/app/core/auth/auth.effects.spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ import {
2222
throwError as observableThrow,
2323
} from 'rxjs';
2424

25-
import {
26-
AppState,
27-
storeModuleConfig,
28-
} from '../../app.reducer';
2925
import {
3026
authMethodsMock,
3127
AuthServiceStub,
3228
} from '../../shared/testing/auth-service.stub';
3329
import { EPersonMock } from '../../shared/testing/eperson.mock';
3430
import { StoreActionTypes } from '../../store.actions';
31+
import { CoreState } from '../core-state.model';
3532
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
3633
import {
3734
AuthActionTypes,
@@ -68,10 +65,17 @@ describe('AuthEffects', () => {
6865
let authServiceStub;
6966
let initialState;
7067
let token;
71-
let store: MockStore<AppState>;
68+
let store: MockStore<CoreState>;
7269

7370
const authorizationService = jasmine.createSpyObj(['invalidateAuthorizationsRequestCache']);
7471

72+
const mockStoreModuleConfig = {
73+
runtimeChecks: {
74+
strictStateImmutability: true,
75+
strictActionImmutability: true,
76+
},
77+
};
78+
7579
function init() {
7680
authServiceStub = new AuthServiceStub();
7781
token = authServiceStub.getToken();
@@ -91,7 +95,7 @@ describe('AuthEffects', () => {
9195
init();
9296
TestBed.configureTestingModule({
9397
imports: [
94-
StoreModule.forRoot({ auth: authReducer }, storeModuleConfig),
98+
StoreModule.forRoot({ auth: authReducer }, mockStoreModuleConfig),
9599
],
96100
providers: [
97101
AuthEffects,

src/app/core/auth/auth.effects.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333
} from 'rxjs/operators';
3434

3535
import { environment } from '../../../environments/environment';
36-
import { AppState } from '../../app.reducer';
3736
import { hasValue } from '../../shared/empty.util';
3837
import { NotificationsActionTypes } from '../../shared/notifications/notifications.actions';
3938
import { StoreActionTypes } from '../../store.actions';
39+
import { CoreState } from '../core-state.model';
4040
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
4141
import { RequestActionTypes } from '../data/request.actions';
4242
import { EPerson } from '../eperson/models/eperson.model';
@@ -322,6 +322,6 @@ export class AuthEffects {
322322
private zone: NgZone,
323323
private authorizationsService: AuthorizationDataService,
324324
private authService: AuthService,
325-
private store: Store<AppState>) {
325+
private store: Store<CoreState>) {
326326
}
327327
}

src/app/core/auth/auth.interceptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import {
2424
map,
2525
} from 'rxjs/operators';
2626

27-
import { AppState } from '../../app.reducer';
2827
import {
2928
hasValue,
3029
isNotEmpty,
3130
isNotNull,
3231
} from '../../shared/empty.util';
32+
import { CoreState } from '../core-state.model';
3333
import { RedirectWhenTokenExpiredAction } from './auth.actions';
3434
import { AuthService } from './auth.service';
3535
import { AuthMethod } from './models/auth.method';
@@ -45,7 +45,7 @@ export class AuthInterceptor implements HttpInterceptor {
4545
// we're creating a refresh token request list
4646
protected refreshTokenRequestUrls = [];
4747

48-
constructor(private inj: Injector, private router: Router, private store: Store<AppState>) {
48+
constructor(private inj: Injector, private router: Router, private store: Store<CoreState>) {
4949
}
5050

5151
/**

src/app/core/auth/auth.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
} from 'rxjs';
2121

2222
import { REQUEST } from '../../../express.tokens';
23-
import { AppState } from '../../app.reducer';
2423
import { getMockTranslateService } from '../../shared/mocks/translate.service.mock';
2524
import { NotificationsService } from '../../shared/notifications/notifications.service';
2625
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
@@ -36,6 +35,7 @@ import {
3635
SpecialGroupDataMock$,
3736
} from '../../shared/testing/special-group.mock';
3837
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
38+
import { CoreState } from '../core-state.model';
3939
import { RemoteData } from '../data/remote-data';
4040
import { EPersonDataService } from '../eperson/eperson-data.service';
4141
import { EPerson } from '../eperson/models/eperson.model';
@@ -282,7 +282,7 @@ describe('AuthService test', () => {
282282
}).compileComponents();
283283
}));
284284

285-
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<AppState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
285+
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<CoreState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
286286
store
287287
.subscribe((state) => {
288288
(state as any).core = Object.create({});
@@ -358,7 +358,7 @@ describe('AuthService test', () => {
358358
}).compileComponents();
359359
}));
360360

361-
beforeEach(inject([ClientCookieService, AuthRequestService, Store, Router, RouteService], (cookieService: ClientCookieService, authReqService: AuthRequestService, store: Store<AppState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
361+
beforeEach(inject([ClientCookieService, AuthRequestService, Store, Router, RouteService], (cookieService: ClientCookieService, authReqService: AuthRequestService, store: Store<CoreState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
362362
const expiredToken: AuthTokenInfo = new AuthTokenInfo('test_token');
363363
expiredToken.expires = Date.now() - (1000 * 60 * 60);
364364
authenticatedState = {
@@ -587,7 +587,7 @@ describe('AuthService test', () => {
587587
}).compileComponents();
588588
}));
589589

590-
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<AppState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
590+
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<CoreState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
591591
store
592592
.subscribe((state) => {
593593
(state as any).core = Object.create({});
@@ -627,7 +627,7 @@ describe('AuthService test', () => {
627627
}).compileComponents();
628628
}));
629629

630-
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<AppState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
630+
beforeEach(inject([CookieService, AuthRequestService, Store, Router, RouteService], (cookieService: CookieService, authReqService: AuthRequestService, store: Store<CoreState>, router: Router, routeService: RouteService, notificationsService: NotificationsService, translateService: TranslateService) => {
631631
store
632632
.subscribe((state) => {
633633
(state as any).core = Object.create({});

src/app/core/auth/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from 'rxjs/operators';
2424

2525
import { environment } from '../../../environments/environment';
26-
import { AppState } from '../../app.reducer';
2726
import {
2827
hasNoValue,
2928
hasValue,
@@ -36,6 +35,7 @@ import {
3635
import { NotificationsService } from '../../shared/notifications/notifications.service';
3736
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
3837
import { followLink } from '../../shared/utils/follow-link-config.model';
38+
import { CoreState } from '../core-state.model';
3939
import {
4040
buildPaginatedList,
4141
PaginatedList,
@@ -115,7 +115,7 @@ export class AuthService {
115115
protected router: Router,
116116
protected routeService: RouteService,
117117
protected storage: CookieService,
118-
protected store: Store<AppState>,
118+
protected store: Store<CoreState>,
119119
protected hardRedirectService: HardRedirectService,
120120
protected notificationService: NotificationsService,
121121
protected translateService: TranslateService,

src/app/core/auth/authenticated.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
switchMap,
1919
} from 'rxjs/operators';
2020

21-
import { AppState } from '../../app.reducer';
21+
import { CoreState } from '../core-state.model';
2222
import {
2323
AuthService,
2424
LOGIN_ROUTE,
@@ -39,7 +39,7 @@ export const authenticatedGuard: CanActivateFn = (
3939
state: RouterStateSnapshot,
4040
authService: AuthService = inject(AuthService),
4141
router: Router = inject(Router),
42-
store: Store<AppState> = inject(Store<AppState>),
42+
store: Store<CoreState> = inject(Store<CoreState>),
4343
): Observable<boolean | UrlTree> => {
4444
const url = state.url;
4545
// redirect to sign in page if user is not authenticated

src/app/core/auth/server-auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import {
1414
REQUEST,
1515
RESPONSE,
1616
} from '../../../express.tokens';
17-
import { AppState } from '../../app.reducer';
1817
import {
1918
hasValue,
2019
isNotEmpty,
2120
} from '../../shared/empty.util';
2221
import { NotificationsService } from '../../shared/notifications/notifications.service';
22+
import { CoreState } from '../core-state.model';
2323
import { RemoteData } from '../data/remote-data';
2424
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
2525
import { EPersonDataService } from '../eperson/eperson-data.service';
@@ -53,7 +53,7 @@ export class ServerAuthService extends AuthService {
5353
protected router: Router,
5454
protected routeService: RouteService,
5555
protected storage: CookieService,
56-
protected store: Store<AppState>,
56+
protected store: Store<CoreState>,
5757
protected hardRedirectService: HardRedirectService,
5858
protected notificationService: NotificationsService,
5959
protected translateService: TranslateService,

0 commit comments

Comments
 (0)