[ADF-5465] Not being redirected to login page when Kerberos is enabled (#7348)

* [ADF-5465] Not being redirected to login page when Kerberos is enabled

* [ci:force] force CI

* [ci:force] force CI
This commit is contained in:
Dharan 2021-11-04 16:25:30 +05:30 committed by GitHub
parent 736b91a65e
commit 15d91ca5e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 9 deletions

View File

@ -567,5 +567,44 @@ describe('User info component', () => {
expect(element.querySelector('.adf-userinfo-profile-image')).not.toBeNull();
});
});
describe('kerberos', () => {
beforeEach(async () => {
isOauthStub.and.returnValue(false);
isEcmLoggedInStub.and.returnValue(false);
isBpmLoggedInStub.and.returnValue(false);
isLoggedInStub.and.returnValue(false);
spyOn(authService, 'isKerberosEnabled').and.returnValue(true);
spyOn(authService, 'isALLProvider').and.returnValue(true);
spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
await whenFixtureReady();
});
it('should show the bpm user information', async () => {
openUserInfo();
const bpmTab = fixture.debugElement.queryAll(By.css('#tab-group-env .mat-tab-labels .mat-tab-label'))[1];
bpmTab.triggerEventHandler('click', null);
fixture.detectChanges();
await fixture.whenStable();
const bpmUsername = fixture.debugElement.query(By.css('#bpm-username'));
const bpmImage = fixture.debugElement.query(By.css('#bpm-user-detail-image'));
expect(bpmImage.properties.src).toContain('app/rest/admin/profile-picture');
expect(bpmUsername.nativeElement.textContent).toContain('fake-bpm-first-name fake-bpm-last-name');
expect(fixture.debugElement.query(By.css('#bpm-tenant')).nativeElement.textContent).toContain('fake-tenant-name');
});
it('should show the ecm user information', async () => {
openUserInfo();
const ecmTab = fixture.debugElement.queryAll(By.css('#tab-group-env .mat-tab-labels .mat-tab-label'))[0];
ecmTab.triggerEventHandler('click', null);
fixture.detectChanges();
await fixture.whenStable();
expect(fixture.debugElement.query(By.css('#ecm-full-name')).nativeElement.textContent).toContain('fake-ecm-first-name fake-ecm-last-name');
expect(fixture.debugElement.query(By.css('#ecm-job-title')).nativeElement.textContent).toContain('job-ecm-test');
});
});
});
});

View File

@ -25,7 +25,6 @@ import { EcmUserService } from '../../services/ecm-user.service';
import { IdentityUserService } from '../../services/identity-user.service';
import { of, Observable, Subject } from 'rxjs';
import { MatMenuTrigger, MenuPositionX, MenuPositionY } from '@angular/material/menu';
import { filter, takeUntil } from 'rxjs/operators';
@Component({
selector: 'adf-userinfo',
@ -75,11 +74,6 @@ export class UserInfoComponent implements OnInit, OnDestroy {
private bpmUserService: BpmUserService,
private identityUserService: IdentityUserService,
private authService: AuthenticationService) {
this.authService.onLogin
.pipe(
filter(() => this.authService.isKerberosEnabled()),
takeUntil(this.destroy$)
).subscribe(() => this.getUserInfo());
}
ngOnInit() {
@ -100,14 +94,14 @@ export class UserInfoComponent implements OnInit, OnDestroy {
this.loadEcmUserInfo();
}
} else if (this.authService.isEcmLoggedIn() && this.authService.isBpmLoggedIn()) {
} else if (this.isAllLoggedIn()) {
this.loadEcmUserInfo();
this.loadBpmUserInfo();
this.mode = 'ALL';
} else if (this.authService.isEcmLoggedIn()) {
} else if (this.isEcmLoggedIn()) {
this.loadEcmUserInfo();
this.mode = 'CONTENT';
} else if (this.authService.isBpmLoggedIn()) {
} else if (this.isBpmLoggedIn()) {
this.loadBpmUserInfo();
this.mode = 'PROCESS';
}
@ -124,6 +118,9 @@ export class UserInfoComponent implements OnInit, OnDestroy {
}
get isLoggedIn(): boolean {
if (this.authService.isKerberosEnabled()) {
return true;
}
return this.authService.isLoggedIn();
}
@ -139,6 +136,18 @@ export class UserInfoComponent implements OnInit, OnDestroy {
this.identityUser$ = of(this.identityUserService.getCurrentUserInfo());
}
private isAllLoggedIn() {
return (this.authService.isEcmLoggedIn() && this.authService.isBpmLoggedIn()) || (this.authService.isALLProvider() && this.authService.isKerberosEnabled());
}
private isBpmLoggedIn() {
return this.authService.isBpmLoggedIn() || (this.authService.isECMProvider() && this.authService.isKerberosEnabled());
}
private isEcmLoggedIn() {
return this.authService.isEcmLoggedIn() || (this.authService.isECMProvider() && this.authService.isKerberosEnabled());
}
stopClosing(event: Event) {
event.stopPropagation();
}