From 04d488b8ea27a2569bd8cedb78075d4b2025e1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Ja=C5=9Bkowski?= <138671284+g-jaskowski@users.noreply.github.com> Date: Mon, 1 Sep 2025 11:28:41 +0200 Subject: [PATCH] [ACS-9768] remove deprecated methods from auth related components (#11031) * [ACS-9768] remove deprecated methods from auth related components * [ACS-9768] remove deprecated method, adjust unit tests * [ACS-9768] fix sonar cloud issues * [ACS-9768] fix auth mocks * [ACS-9768] fix sonar cloud alerts * [ACS-9768] update method name in docs --- .../core/services/user-preferences.service.md | 2 +- .../common/services/discovery-api.service.ts | 7 ++- .../mock/download-zip-service.mock.ts | 1 - .../node-download.directive.spec.ts | 2 +- .../search-control.component.spec.ts | 2 +- .../components/search-control.component.ts | 7 ++- .../basic-alfresco-auth.service.spec.ts | 16 ------ .../basic-auth/basic-alfresco-auth.service.ts | 47 ++-------------- .../auth/guard/auth-guard-bpm.service.spec.ts | 12 ++-- .../auth/guard/auth-guard-ecm.service.spec.ts | 14 ++--- .../lib/auth/guard/auth-guard-ecm.service.ts | 2 +- .../lib/auth/guard/auth-guard.service.spec.ts | 2 +- .../authentication-service.interface.ts | 10 ---- .../oidc/oidc-authentication.service.spec.ts | 56 ------------------- .../auth/oidc/oidc-authentication.service.ts | 38 ------------- .../services/authentication.service.spec.ts | 13 ++--- .../auth/services/authentication.service.ts | 45 ++------------- .../services/base-authentication.service.ts | 18 ++---- .../app-list-cloud.component.spec.ts | 2 +- .../components/form-cloud.component.spec.ts | 2 +- ...dit-process-filter-cloud.component.spec.ts | 2 +- .../mock/edit-task-filter-cloud.mock.ts | 2 +- .../task-header-cloud.component.spec.ts | 2 +- 23 files changed, 51 insertions(+), 253 deletions(-) diff --git a/docs/core/services/user-preferences.service.md b/docs/core/services/user-preferences.service.md index 1d8b5b5acb..a898c08bf4 100644 --- a/docs/core/services/user-preferences.service.md +++ b/docs/core/services/user-preferences.service.md @@ -65,7 +65,7 @@ class AppComponent { onLoggedIn() { this.userPreferences.setStoragePrefix( - this.authService.getEcmUsername() + this.authService.getUsername() ); } } diff --git a/lib/content-services/src/lib/common/services/discovery-api.service.ts b/lib/content-services/src/lib/common/services/discovery-api.service.ts index 8d7adf1d8c..483ea21c86 100644 --- a/lib/content-services/src/lib/common/services/discovery-api.service.ts +++ b/lib/content-services/src/lib/common/services/discovery-api.service.ts @@ -38,11 +38,14 @@ export class DiscoveryApiService { */ ecmProductInfo$ = new Subject(); - constructor(private authenticationService: AuthenticationService, private alfrescoApiService: AlfrescoApiService) { + constructor( + private readonly authenticationService: AuthenticationService, + private readonly alfrescoApiService: AlfrescoApiService + ) { this.authenticationService.onLogin.subscribe(() => { this.alfrescoApiService.alfrescoApiInitialized .pipe( - filter(() => this.authenticationService.isEcmLoggedIn()), + filter(() => this.authenticationService.isLoggedIn()), take(1), switchMap(() => this.getEcmProductInfo()) ) diff --git a/lib/content-services/src/lib/dialogs/download-zip/mock/download-zip-service.mock.ts b/lib/content-services/src/lib/dialogs/download-zip/mock/download-zip-service.mock.ts index c537b4dfaa..7ef702631b 100644 --- a/lib/content-services/src/lib/dialogs/download-zip/mock/download-zip-service.mock.ts +++ b/lib/content-services/src/lib/dialogs/download-zip/mock/download-zip-service.mock.ts @@ -36,7 +36,6 @@ class AlfrescoApiMock { isOauthConfiguration = () => true; isLoggedIn = () => true; isEcmConfiguration = () => true; - isEcmLoggedIn = () => true; } export class ContentApiMock { diff --git a/lib/content-services/src/lib/directives/node-download.directive.spec.ts b/lib/content-services/src/lib/directives/node-download.directive.spec.ts index 2edf5c8b86..165686b5cd 100755 --- a/lib/content-services/src/lib/directives/node-download.directive.spec.ts +++ b/lib/content-services/src/lib/directives/node-download.directive.spec.ts @@ -50,7 +50,7 @@ describe('NodeDownloadDirective', () => { oauth2Auth: { callCustomApi: () => Promise.resolve() }, - isEcmLoggedIn: jasmine.createSpy('isEcmLoggedIn'), + isLoggedIn: jasmine.createSpy('isLoggedIn'), reply: jasmine.createSpy('reply') }; diff --git a/lib/content-services/src/lib/search/components/search-control.component.spec.ts b/lib/content-services/src/lib/search/components/search-control.component.spec.ts index 5a751f4f55..37af023fde 100644 --- a/lib/content-services/src/lib/search/components/search-control.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-control.component.spec.ts @@ -69,7 +69,7 @@ describe('SearchControlComponent', () => { searchService = TestBed.inject(SearchService); authService = TestBed.inject(AuthenticationService); userPreferencesService = TestBed.inject(UserPreferencesService); - spyOn(authService, 'isEcmLoggedIn').and.returnValue(true); + spyOn(authService, 'isLoggedIn').and.returnValue(true); component = fixture.componentInstance; element = fixture.nativeElement; diff --git a/lib/content-services/src/lib/search/components/search-control.component.ts b/lib/content-services/src/lib/search/components/search-control.component.ts index e18e3e3e5c..79deaaf780 100644 --- a/lib/content-services/src/lib/search/components/search-control.component.ts +++ b/lib/content-services/src/lib/search/components/search-control.component.ts @@ -109,13 +109,16 @@ export class SearchControlComponent { noSearchResultTemplate: TemplateRef = null; searchTerm: string = ''; - constructor(public authService: AuthenticationService, private thumbnailService: ThumbnailService) {} + constructor( + public authService: AuthenticationService, + private readonly thumbnailService: ThumbnailService + ) {} isNoSearchTemplatePresent(): boolean { return !!this.emptySearchTemplate; } isLoggedIn(): boolean { - return this.authService.isEcmLoggedIn(); + return this.authService.isLoggedIn(); } inputChange(value: string) { diff --git a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.spec.ts b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.spec.ts index e7bb0f1d95..edd1606641 100644 --- a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.spec.ts +++ b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.spec.ts @@ -127,22 +127,6 @@ describe('BasicAlfrescoAuthService', () => { }); }); - it('isBpmLoggedIn should return value from processAuth', () => { - spyOn(processAuth, 'isLoggedIn').and.returnValue(true); - const result = basicAlfrescoAuthService.isBpmLoggedIn(); - - expect(result).toBeTrue(); - expect(processAuth.isLoggedIn).toHaveBeenCalled(); - }); - - it('isEcmLoggedIn should return value from contentAuth', () => { - spyOn(contentAuth, 'isLoggedIn').and.returnValue(true); - const result = basicAlfrescoAuthService.isEcmLoggedIn(); - - expect(result).toBeTrue(); - expect(contentAuth.isLoggedIn).toHaveBeenCalled(); - }); - describe('isLoggedIn', () => { let contentAuthSpy: jasmine.Spy; let processAuthSpy: jasmine.Spy; diff --git a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts index 62a2384217..5614b5b0ca 100644 --- a/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts +++ b/lib/core/src/lib/auth/basic-auth/basic-alfresco-auth.service.ts @@ -43,7 +43,12 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService { type: 'basic' }; - constructor(appConfig: AppConfigService, cookie: CookieService, private contentAuth: ContentAuth, private processAuth: ProcessAuth) { + constructor( + appConfig: AppConfigService, + cookie: CookieService, + private readonly contentAuth: ContentAuth, + private readonly processAuth: ProcessAuth + ) { super(appConfig, cookie); this.appConfig.onLoad.subscribe(() => { @@ -214,30 +219,6 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService { } } - /** - * @deprecated - * @returns content auth token - */ - getTicketEcm(): string { - return this.contentAuth.getToken(); - } - - /** - * @deprecated - * @returns process auth token - */ - getTicketBpm(): string { - return this.processAuth.getToken(); - } - - isBpmLoggedIn(): boolean { - return this.processAuth.isLoggedIn(); - } - - isEcmLoggedIn(): boolean { - return this.contentAuth.isLoggedIn(); - } - isLoggedIn(): boolean { const authWithCredentials = this.isKerberosEnabled(); @@ -317,22 +298,6 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService { return this.redirectUrl && (this.redirectUrl.provider === 'ALL' || provider === 'ALL'); } - /** - * @deprecated use `getUsername()` instead - * @returns the username of the authenticated user - */ - getBpmUsername(): string { - return this.processAuth.getUsername(); - } - - /** - * @deprecated use `getUsername()` instead - * @returns the username of the authenticated user - */ - getEcmUsername(): string { - return this.contentAuth.getUsername(); - } - /** * Gets the username of the authenticated user. * diff --git a/lib/core/src/lib/auth/guard/auth-guard-bpm.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard-bpm.service.spec.ts index 995c06d141..dd1ba51397 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-bpm.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-bpm.service.spec.ts @@ -71,7 +71,7 @@ describe('AuthGuardService BPM', () => { }); it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); spyOn(oidcAuthenticationService, 'isPublicUrl').and.returnValue(false); spyOn(oidcAuthenticationService, 'ssoLogin').and.stub(); @@ -101,7 +101,7 @@ describe('AuthGuardService BPM', () => { }); it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); + spyOn(authService, 'isLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; authGuard = TestBed.runInInjectionContext(() => AuthGuardBpm(route, state)) as Promise; @@ -110,7 +110,7 @@ describe('AuthGuardService BPM', () => { }); it('if the alfresco js api is NOT logged in should canActivate be false', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); authGuard = TestBed.runInInjectionContext(() => AuthGuardBpm(route, state)) as Promise; @@ -119,7 +119,7 @@ describe('AuthGuardService BPM', () => { it('if the alfresco js api is NOT logged in should trigger a redirect event', async () => { appConfigService.config.loginRoute = 'login'; - spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); authGuard = TestBed.runInInjectionContext(() => AuthGuardBpm(route, state)) as Promise; @@ -128,7 +128,7 @@ describe('AuthGuardService BPM', () => { }); it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = false; @@ -139,7 +139,7 @@ describe('AuthGuardService BPM', () => { }); it('should redirect url if NOT logged in and isOAuth but no silentLogin configured', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = undefined; diff --git a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts index 1eec6a2a0b..143a52b908 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.spec.ts @@ -71,7 +71,7 @@ describe('AuthGuardService ECM', () => { }); it('if the alfresco js api is logged in should canActivate be true', async () => { - spyOn(authService, 'isEcmLoggedIn').and.returnValue(true); + spyOn(authService, 'isLoggedIn').and.returnValue(true); authGuard = TestBed.runInInjectionContext(() => AuthGuardEcm(route, state)) as Promise; @@ -79,7 +79,7 @@ describe('AuthGuardService ECM', () => { }); it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); + spyOn(authService, 'isLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; authGuard = TestBed.runInInjectionContext(() => AuthGuardEcm(route, state)) as Promise; @@ -88,7 +88,7 @@ describe('AuthGuardService ECM', () => { }); it('if the alfresco js api is NOT logged in should canActivate be false', async () => { - spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); authGuard = TestBed.runInInjectionContext(() => AuthGuardEcm(route, state)) as Promise; @@ -97,7 +97,7 @@ describe('AuthGuardService ECM', () => { it('if the alfresco js api is NOT logged in should trigger a redirect event', async () => { appConfigService.config.loginRoute = 'login'; - spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); authGuard = TestBed.runInInjectionContext(() => AuthGuardEcm(route, state)) as Promise; @@ -106,7 +106,7 @@ describe('AuthGuardService ECM', () => { }); it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async () => { - spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = false; @@ -117,7 +117,7 @@ describe('AuthGuardService ECM', () => { }); it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async () => { - spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); spyOn(oidcAuthenticationService, 'isPublicUrl').and.returnValue(false); spyOn(oidcAuthenticationService, 'ssoLogin').and.stub(); @@ -139,7 +139,7 @@ describe('AuthGuardService ECM', () => { }); it('should not redirect url if NOT logged in and isOAuth but no silentLogin configured', async () => { - spyOn(authService, 'isEcmLoggedIn').and.returnValue(false); + spyOn(authService, 'isLoggedIn').and.returnValue(false); spyOn(authService, 'isOauth').and.returnValue(true); appConfigService.config.oauth2.silentLogin = undefined; diff --git a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.ts b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.ts index c57dadee63..3bcf9483c8 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-ecm.service.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-ecm.service.ts @@ -28,7 +28,7 @@ export const AuthGuardEcm: CanActivateFn = async (_: ActivatedRouteSnapshot, sta return authGuardBaseService.redirectSSOSuccessURL(); } - if (authenticationService.isEcmLoggedIn() || authGuardBaseService.withCredentials) { + if (authenticationService.isLoggedIn() || authGuardBaseService.withCredentials) { return true; } diff --git a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts index 6a536335c9..5400aa5c04 100644 --- a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts @@ -89,7 +89,7 @@ describe('AuthGuardService', () => { }); it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => { - spyOn(authService, 'isBpmLoggedIn').and.returnValue(true); + spyOn(authService, 'isLoggedIn').and.returnValue(true); appConfigService.config.auth.withCredentials = true; authGuard = TestBed.runInInjectionContext(() => AuthGuard(route, state)) as Promise; diff --git a/lib/core/src/lib/auth/interfaces/authentication-service.interface.ts b/lib/core/src/lib/auth/interfaces/authentication-service.interface.ts index 1c94bec7a2..666215c551 100644 --- a/lib/core/src/lib/auth/interfaces/authentication-service.interface.ts +++ b/lib/core/src/lib/auth/interfaces/authentication-service.interface.ts @@ -42,14 +42,4 @@ export interface AuthenticationServiceInterface { getAuthHeaders(requestUrl: string, header: HttpHeaders): HttpHeaders; addTokenToHeader(requestUrl: string, headersArg?: HttpHeaders): Observable; reset(): void; - - /** @deprecated use `isLoggedIn` instead, use `isECMProvider` if you need to know the auth type */ - isEcmLoggedIn(): boolean; - /** @deprecated use `isLoggedIn` instead, use `isBPMProvider` if you need to know the auth type */ - isBpmLoggedIn(): boolean; - - /** @deprecated use `getUsername` instead */ - getEcmUsername(): string; - /** @deprecated use `getUsername` instead */ - getBpmUsername(): string; } diff --git a/lib/core/src/lib/auth/oidc/oidc-authentication.service.spec.ts b/lib/core/src/lib/auth/oidc/oidc-authentication.service.spec.ts index e7323bb58c..b489541e99 100644 --- a/lib/core/src/lib/auth/oidc/oidc-authentication.service.spec.ts +++ b/lib/core/src/lib/auth/oidc/oidc-authentication.service.spec.ts @@ -66,7 +66,6 @@ const mockAuthService = { describe('OidcAuthenticationService', () => { let service: OidcAuthenticationService; let oauthService: OAuthService; - let appConfig: AppConfigService; beforeEach(() => { TestBed.configureTestingModule({ @@ -81,7 +80,6 @@ describe('OidcAuthenticationService', () => { }); service = TestBed.inject(OidcAuthenticationService); oauthService = TestBed.inject(OAuthService); - appConfig = TestBed.inject(AppConfigService); }); it('should be created', () => { @@ -189,60 +187,6 @@ describe('OidcAuthenticationService', () => { expect(service.isLoggedIn()).toBeFalse(); }); }); - - describe('isEcmLoggedIn', () => { - beforeEach(() => { - mockOAuthService.hasValidAccessToken.and.returnValue(true); - mockOAuthService.hasValidIdToken.and.returnValue(true); - }); - - it('should return true if is ECM provider', () => { - spyOn(appConfig, 'get').and.returnValue('ECM'); - expect(service.isEcmLoggedIn()).toBeTrue(); - }); - - it('should return true if is all provider', () => { - spyOn(appConfig, 'get').and.returnValue('ALL'); - expect(service.isEcmLoggedIn()).toBeTrue(); - }); - - it('should return false if is not ECM provider', () => { - spyOn(appConfig, 'get').and.returnValue('BPM'); - expect(service.isEcmLoggedIn()).toBeFalse(); - }); - - it('should return false if provider is not defined', () => { - spyOn(appConfig, 'get').and.returnValue(undefined); - expect(service.isEcmLoggedIn()).toBeFalse(); - }); - }); - - describe('isBpmLoggedIn', () => { - beforeEach(() => { - mockOAuthService.hasValidAccessToken.and.returnValue(true); - mockOAuthService.hasValidIdToken.and.returnValue(true); - }); - - it('should return true if is BPM provider', () => { - spyOn(appConfig, 'get').and.returnValue('BPM'); - expect(service.isBpmLoggedIn()).toBeTrue(); - }); - - it('should return true if is all provider', () => { - spyOn(appConfig, 'get').and.returnValue('ALL'); - expect(service.isBpmLoggedIn()).toBeTrue(); - }); - - it('should return false if is not BPM provider', () => { - spyOn(appConfig, 'get').and.returnValue('ECM'); - expect(service.isBpmLoggedIn()).toBeFalse(); - }); - - it('should return false if provider is not defined', () => { - spyOn(appConfig, 'get').and.returnValue(undefined); - expect(service.isBpmLoggedIn()).toBeFalse(); - }); - }); }); describe('OidcAuthenticationService shouldPerformSsoLogin', () => { diff --git a/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts b/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts index 06c3df2f37..9809b7a676 100644 --- a/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts +++ b/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts @@ -56,28 +56,6 @@ export class OidcAuthenticationService extends BaseAuthenticationService { map(([authenticated, isDiscoveryDocumentLoaded]) => !authenticated && isDiscoveryDocumentLoaded) ); - /** - * @deprecated use `isLoggedIn` instead - * @returns true if the ECM provider is logged in - */ - isEcmLoggedIn(): boolean { - if (this.isECMProvider() || this.isALLProvider()) { - return this.isLoggedIn(); - } - return false; - } - - /** - * @deprecated use `isLoggedIn` instead - * @returns true if the BPM provider is logged in - */ - isBpmLoggedIn(): boolean { - if (this.isBPMProvider() || this.isALLProvider()) { - return this.isLoggedIn(); - } - return false; - } - isLoggedIn(): boolean { return this.oauthService.hasValidAccessToken() && this.oauthService.hasValidIdToken(); } @@ -132,22 +110,6 @@ export class OidcAuthenticationService extends BaseAuthenticationService { return this.jwtHelperService.getValueFromLocalToken(JwtHelperService.USER_PREFERRED_USERNAME); } - /** - * @deprecated use `getUsername` instead - * @returns the logged username - */ - getEcmUsername(): string { - return this.getUsername(); - } - - /** - * @deprecated use `getUsername` instead - * @returns the logged username - */ - getBpmUsername(): string { - return this.getUsername(); - } - ssoLogin(redirectUrl?: string) { this.auth.login(redirectUrl); } diff --git a/lib/core/src/lib/auth/services/authentication.service.spec.ts b/lib/core/src/lib/auth/services/authentication.service.spec.ts index d4cd488aaa..7a3d6ef57b 100644 --- a/lib/core/src/lib/auth/services/authentication.service.spec.ts +++ b/lib/core/src/lib/auth/services/authentication.service.spec.ts @@ -140,7 +140,7 @@ describe('AuthenticationService', () => { spyOn(authService, 'isECMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); - expect(authService.isEcmLoggedIn()).toBeFalsy(); + expect(authService.isLoggedIn()).toBeFalsy(); }); it('should require remember me set for ECM check', () => { @@ -149,7 +149,7 @@ describe('AuthenticationService', () => { spyOn(authService, 'isECMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); - expect(authService.isEcmLoggedIn()).toBeFalsy(); + expect(authService.isLoggedIn()).toBeFalsy(); }); it('[ECM] should login in the ECM if no provider are defined calling the login', async () => { @@ -167,7 +167,6 @@ describe('AuthenticationService', () => { it('[ECM] should return false if the user is not logged in', () => { expect(authService.isLoggedIn()).toBe(false); - expect(authService.isEcmLoggedIn()).toBe(false); }); it('[ECM] should set/get redirectUrl when provider is ECM', () => { @@ -199,10 +198,6 @@ describe('AuthenticationService', () => { it('[ECM] should return isALLProvider false', () => { expect(authService.isALLProvider()).toBe(false); }); - - it('[ECM] should return isBpmLoggedIn false', () => { - expect(authService.isBpmLoggedIn()).toBe(false); - }); }); describe('when the setting is BPM', () => { @@ -217,7 +212,7 @@ describe('AuthenticationService', () => { spyOn(authService, 'isBPMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); - expect(authService.isBpmLoggedIn()).toBeFalsy(); + expect(authService.isLoggedIn()).toBeFalsy(); }); it('should not require cookie service enabled for BPM check', () => { @@ -225,7 +220,7 @@ describe('AuthenticationService', () => { spyOn(basicAlfrescoAuthService, 'isRememberMeSet').and.returnValue(false); spyOn(authService, 'isBPMProvider').and.returnValue(true); - expect(authService.isBpmLoggedIn()).toBeFalsy(); + expect(authService.isLoggedIn()).toBeFalsy(); }); it('[BPM] should return an error when the logout return error', async () => { diff --git a/lib/core/src/lib/auth/services/authentication.service.ts b/lib/core/src/lib/auth/services/authentication.service.ts index 1dfb9eef4f..aa5d3bb1a9 100644 --- a/lib/core/src/lib/auth/services/authentication.service.ts +++ b/lib/core/src/lib/auth/services/authentication.service.ts @@ -32,7 +32,10 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee onLogout: Subject = new Subject(); onTokenReceived: Subject = new Subject(); - constructor(private injector: Injector, private redirectAuthService: RedirectAuthService) { + constructor( + private readonly injector: Injector, + private readonly redirectAuthService: RedirectAuthService + ) { this.redirectAuthService.onLogin.subscribe((value) => this.onLogin.next(value)); this.redirectAuthService.onTokenReceived.subscribe((value) => this.onTokenReceived.next(value)); @@ -116,30 +119,6 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee } } - /** - * @deprecated use `isLoggedIn` instead - * @returns true if the ECM provider is logged in - */ - isEcmLoggedIn(): boolean { - if (this.isOauth()) { - return this.oidcAuthenticationService.isLoggedIn(); - } else { - return this.basicAlfrescoAuthService.isEcmLoggedIn(); - } - } - - /** - * @deprecated use `isLoggedIn` instead - * @returns true if the BPM provider is logged in - */ - isBpmLoggedIn(): boolean { - if (this.isOauth()) { - return this.oidcAuthenticationService.isLoggedIn(); - } else { - return this.basicAlfrescoAuthService.isBpmLoggedIn(); - } - } - reset(): void { if (this.isOauth()) { return this.oidcAuthenticationService.reset(); @@ -169,22 +148,6 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee } } - /** - * @deprecated use `getUsername` instead - * @returns the logged username - */ - getEcmUsername(): string { - return this.getUsername(); - } - - /** - * @deprecated use `getUsername` instead - * @returns the logged username - */ - getBpmUsername(): string { - return this.getUsername(); - } - getAuthHeaders(requestUrl: string, headers: HttpHeaders): HttpHeaders { if (this.isOauth()) { return this.oidcAuthenticationService.getAuthHeaders(requestUrl, headers); diff --git a/lib/core/src/lib/auth/services/base-authentication.service.ts b/lib/core/src/lib/auth/services/base-authentication.service.ts index 3a88d23301..057a461551 100644 --- a/lib/core/src/lib/auth/services/base-authentication.service.ts +++ b/lib/core/src/lib/auth/services/base-authentication.service.ts @@ -35,7 +35,10 @@ export abstract class BaseAuthenticationService implements AuthenticationService onLogin = new ReplaySubject(1); onLogout = new ReplaySubject(1); - protected constructor(protected appConfig: AppConfigService, protected cookie: CookieService) { + protected constructor( + protected appConfig: AppConfigService, + protected cookie: CookieService + ) { ee(this); } @@ -43,22 +46,9 @@ export abstract class BaseAuthenticationService implements AuthenticationService abstract getToken(): string; abstract isLoggedIn(): boolean; abstract logout(): any; - - /** @deprecated use `isLoggedIn` instead */ - abstract isEcmLoggedIn(): boolean; - - /** @deprecated use `isLoggedIn` instead */ - abstract isBpmLoggedIn(): boolean; - abstract reset(): void; abstract getUsername(): string; - /** @deprecated use `getUsername` instead */ - abstract getEcmUsername(): string; - - /** @deprecated use `getUsername` instead */ - abstract getBpmUsername(): string; - /** * Adds the auth token to an HTTP header using the 'bearer' scheme. * diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts index 5a8b1685e5..aa3445f25b 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts @@ -36,7 +36,7 @@ describe('AppListCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn: () => false, + isLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index a932cec322..59d7b5ebfb 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -69,7 +69,7 @@ const mockOauth2Auth: any = { oauth2Auth: { callCustomApi: () => Promise.resolve() }, - isEcmLoggedIn: jasmine.createSpy('isEcmLoggedIn'), + isLoggedIn: jasmine.createSpy('isLoggedIn'), reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter/edit-process-filter-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter/edit-process-filter-cloud.component.spec.ts index 282d751b58..f4c9548b2a 100644 --- a/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter/edit-process-filter-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-filters/components/edit-process-filter/edit-process-filter-cloud.component.spec.ts @@ -83,7 +83,7 @@ describe('EditProcessFilterCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn: () => false, + isLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/task/task-filters/mock/edit-task-filter-cloud.mock.ts b/lib/process-services-cloud/src/lib/task/task-filters/mock/edit-task-filter-cloud.mock.ts index d950a38eb7..62477fcaa6 100644 --- a/lib/process-services-cloud/src/lib/task/task-filters/mock/edit-task-filter-cloud.mock.ts +++ b/lib/process-services-cloud/src/lib/task/task-filters/mock/edit-task-filter-cloud.mock.ts @@ -23,7 +23,7 @@ export const mockAlfrescoApi: any = { oauth2Auth: { callCustomApi: () => Promise.resolve(fakeApplicationInstance) }, - isEcmLoggedIn: () => false, + isLoggedIn: () => false, reply: jasmine.createSpy('reply') }; diff --git a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts index e44a64fb68..5c1fc0821f 100644 --- a/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-header/components/task-header-cloud.component.spec.ts @@ -53,7 +53,7 @@ describe('TaskHeaderCloudComponent', () => { oauth2Auth: { callCustomApi: () => Promise.resolve({}) }, - isEcmLoggedIn: () => false, + isLoggedIn: () => false, reply: jasmine.createSpy('reply') };