Update branch for JS-API PR#438 (#8010)

* [ci:force][auto-commit] Update JS-API to 5.2.0-443 for branch: update-js-api originated from JS-API PR: 443

* [ADF-5507] Fix failing unit tests for auth service

* remove unnecessary method

Co-authored-by: Michal Kinas <michal.kinas@hyland.com>
Co-authored-by: eromano <eugenioromano16@gmail.com>
This commit is contained in:
Alfresco Build
2022-11-29 13:39:50 +01:00
committed by GitHub
parent 740e3cef9b
commit 97e6129b6e
14 changed files with 22 additions and 53 deletions

View File

@@ -42,7 +42,7 @@
"@angular/router": ">=10.0.2",
"@mat-datetimepicker/core": ">=4.1.0",
"@mat-datetimepicker/moment": ">=4.1.0",
"@alfresco/js-api": "5.2.0-435",
"@alfresco/js-api": "5.2.0-443",
"@alfresco/adf-extensions": "5.1.0",
"@ngx-translate/core": ">=13.0.0",
"minimatch-browser": ">=1.0.0",

View File

@@ -23,7 +23,6 @@ import { AppConfigService } from '../app-config/app-config.service';
import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { PersonEntry } from '@alfresco/js-api';
declare let jasmine: any;
@@ -67,12 +66,8 @@ describe('AuthenticationService', () => {
appConfigService.config.auth = { withCredentials: true };
});
it('should emit login event for kerberos', (done) => {
spyOn(authService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(new PersonEntry()));
spyOn(authService.profileApi, 'getProfile').and.returnValue(Promise.resolve({}));
it('should emit login event for kerberos', (done) => {
const disposableLogin = authService.onLogin.subscribe(() => {
expect(authService.profileApi.getProfile).toHaveBeenCalledTimes(1);
expect(authService.peopleApi.getPerson).toHaveBeenCalledTimes(1);
disposableLogin.unsubscribe();
done();
});
@@ -85,6 +80,7 @@ describe('AuthenticationService', () => {
const fakeECMLoginResponse = { type: 'ECM', ticket: 'fake-post-ticket' };
beforeEach(() => {
appConfigService.config.auth = { withCredentials: false };
appConfigService.config.providers = 'ECM';
appConfigService.load();
apiService.reset();

View File

@@ -17,13 +17,13 @@
import { Authentication } from '@alfresco/adf-core/auth';
import { Injectable } from '@angular/core';
import { Observable, from, throwError, Observer, ReplaySubject, forkJoin } from 'rxjs';
import { Observable, from, throwError, Observer, ReplaySubject } from 'rxjs';
import { AlfrescoApiService } from './alfresco-api.service';
import { CookieService } from './cookie.service';
import { LogService } from './log.service';
import { RedirectionModel } from '../models/redirection.model';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { PeopleApi, UserProfileApi, UserRepresentation } from '@alfresco/js-api';
import { UserProfileApi, UserRepresentation } from '@alfresco/js-api';
import { map, catchError, tap } from 'rxjs/operators';
import { HttpHeaders } from '@angular/common/http';
import { JwtHelperService } from './jwt-helper.service';
@@ -49,12 +49,6 @@ export class AuthenticationService extends Authentication {
*/
onLogout: ReplaySubject<any> = new ReplaySubject<any>(1);
_peopleApi: PeopleApi;
get peopleApi(): PeopleApi {
this._peopleApi = this._peopleApi ?? new PeopleApi(this.alfrescoApi.getInstance());
return this._peopleApi;
}
_profileApi: UserProfileApi;
get profileApi(): UserProfileApi {
this._profileApi = this._profileApi ?? new UserProfileApi(this.alfrescoApi.getInstance());
@@ -72,30 +66,9 @@ export class AuthenticationService extends Authentication {
this.alfrescoApi.getInstance().reply('logged-in', () => {
this.onLogin.next();
});
if (this.isKerberosEnabled()) {
this.loadUserDetails();
}
});
}
private loadUserDetails() {
if (this.isALLProvider()) {
const ecmUser$ = from(this.peopleApi.getPerson('-me-'));
const bpmUser$ = this.getBpmLoggedUser();
forkJoin([ecmUser$, bpmUser$]).subscribe(() => this.onLogin.next());
} else if (this.isECMProvider()) {
const ecmUser$ = from(this.peopleApi.getPerson('-me-'));
ecmUser$.subscribe(() => this.onLogin.next());
} else {
const bpmUser$ = this.getBpmLoggedUser();
bpmUser$.subscribe(() => this.onLogin.next());
}
}
/**
* Checks if the user logged in.
*