Added typedoc and minor test update

This commit is contained in:
Michael W Spalti
2023-04-19 11:36:42 -07:00
parent e336660cdd
commit b1f3b785e1
5 changed files with 17 additions and 6 deletions

View File

@@ -221,7 +221,8 @@ describe('AuthEffects', () => {
expect(authEffects.checkTokenCookie$).toBeObservable(expected); expect(authEffects.checkTokenCookie$).toBeObservable(expected);
authEffects.checkTokenCookie$.subscribe(() => { authEffects.checkTokenCookie$.subscribe(() => {
expect(authServiceStub.setExternalAuthStatus).toHaveBeenCalledWith(true); expect(authServiceStub.setExternalAuthStatus).toHaveBeenCalled();
expect(authServiceStub.isExternalAuthentication).toBeTrue();
expect((authEffects as any).authorizationsService.invalidateAuthorizationsRequestCache).toHaveBeenCalled(); expect((authEffects as any).authorizationsService.invalidateAuthorizationsRequestCache).toHaveBeenCalled();
}); });
}); });

View File

@@ -156,10 +156,19 @@ export class AuthService {
return this.store.pipe(select(isAuthenticatedLoaded)); return this.store.pipe(select(isAuthenticatedLoaded));
} }
/**
* Used to set the external authentication status when authenticating via an
* external authentication system (e.g. Shibboleth).
* @param external
*/
public setExternalAuthStatus(external: boolean) { public setExternalAuthStatus(external: boolean) {
this.store.dispatch(new SetAuthCookieStatus(external)); this.store.dispatch(new SetAuthCookieStatus(external));
} }
/**
* Returns true if an external authentication system (e.g. Shibboleth) is being used
* for authentication. Returns false otherwise.
*/
public isExternalAuthentication(): Observable<boolean> { public isExternalAuthentication(): Observable<boolean> {
return this.store.pipe( return this.store.pipe(
select(getExternalAuthCookieStatus)); select(getExternalAuthCookieStatus));

View File

@@ -181,7 +181,7 @@ export const isAuthenticated = createSelector(getAuthState, _isAuthenticated);
export const isAuthenticatedLoaded = createSelector(getAuthState, _isAuthenticatedLoaded); export const isAuthenticatedLoaded = createSelector(getAuthState, _isAuthenticatedLoaded);
/** /**
* Returns the authentication cookie status. Expect to be ture when external authentication * Returns the authentication cookie status. Expect to be true when external authentication
* is used. * is used.
* @function getExternalAuthCookieStatus * @function getExternalAuthCookieStatus
* @param {AuthState} state * @param {AuthState} state

View File

@@ -17,6 +17,7 @@ export class AuthServiceStub {
token: AuthTokenInfo = new AuthTokenInfo('token_test'); token: AuthTokenInfo = new AuthTokenInfo('token_test');
impersonating: string; impersonating: string;
private _tokenExpired = false; private _tokenExpired = false;
private _isExternalAuth = false;
private redirectUrl; private redirectUrl;
constructor() { constructor() {
@@ -123,11 +124,11 @@ export class AuthServiceStub {
return; return;
} }
setExternalAuthStatus(externalCookie: boolean) { setExternalAuthStatus(externalCookie: boolean) {
return; this._isExternalAuth = externalCookie;
} }
isExternalAuthentication(): Observable<boolean> { isExternalAuthentication(): Observable<boolean> {
return; return observableOf(this._isExternalAuth);
} }
retrieveAuthMethodsFromAuthStatus(status: AuthStatus) { retrieveAuthMethodsFromAuthStatus(status: AuthStatus) {

View File

@@ -56,7 +56,7 @@ export class BrowserInitService extends InitService {
protected authService: AuthService, protected authService: AuthService,
protected themeService: ThemeService, protected themeService: ThemeService,
protected menuService: MenuService, protected menuService: MenuService,
private rootDatatService: RootDataService private rootDataService: RootDataService
) { ) {
super( super(
store, store,
@@ -153,7 +153,7 @@ export class BrowserInitService extends InitService {
filter((externalAuth: boolean) => externalAuth) filter((externalAuth: boolean) => externalAuth)
).subscribe(() => { ).subscribe(() => {
// Clear the transferState data. // Clear the transferState data.
this.rootDatatService.invalidateRootCache(); this.rootDataService.invalidateRootCache();
this.authService.setExternalAuthStatus(false); this.authService.setExternalAuthStatus(false);
} }
); );