[ADF-5009] close all the dialogs after false canActivate event (#5312)

* close all the dialogs after false canActivate event

* Update auth-guard-bpm.service.spec.ts

* sso fix

* fix lint
This commit is contained in:
Eugenio Romano
2020-01-02 11:21:10 +01:00
committed by Denys Vuika
parent d7e56b641e
commit 9c83c35e61
8 changed files with 86 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ import { setupTestBed } from '../testing/setupTestBed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
import { JwtHelperService } from './jwt-helper.service';
import { MatDialog } from '@angular/material';
describe('Auth Guard SSO role service', () => {
@@ -164,4 +165,21 @@ describe('Auth Guard SSO role service', () => {
expect(authGuard.canActivate(route)).toBeFalsy();
});
it('Should canActivate be false hasRealm is true and hasClientRole is false', () => {
const materialDialog = TestBed.get(MatDialog);
spyOn(materialDialog, 'closeAll');
const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
spyOn(jwtHelperService, 'hasRealmRoles').and.returnValue(true);
spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false);
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
expect(authGuard.canActivate(route)).toBeFalsy();
expect(materialDialog.closeAll).toHaveBeenCalled();
});
});