mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
fix "ng lint" command (#5012)
* update to latest js-api * fix the "ng lint" command * fix linting issues * fix lint issues * lint fixes * code fixes * fix html * fix html * update tests * test fixes * update tests * fix tests and api * fix code
This commit is contained in:
committed by
Eugenio Romano
parent
140c64b79f
commit
edc0945f39
@@ -33,7 +33,7 @@ export class AuthGuardBpm extends AuthGuardBase {
|
||||
super(authenticationService, router, appConfigService);
|
||||
}
|
||||
|
||||
checkLogin(activeRoute: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
if (this.authenticationService.isBpmLoggedIn() || this.withCredentials) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ export class AuthGuardEcm extends AuthGuardBase {
|
||||
super(authenticationService, router, appConfigService);
|
||||
}
|
||||
|
||||
checkLogin(activeRoute: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeTruthy();
|
||||
expect(authGuard.canActivate(router)).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('Should canActivate be false if the Role is not present int the JWT token', async(() => {
|
||||
@@ -56,7 +56,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(router)).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('Should not redirect if canActivate is', async(() => {
|
||||
@@ -67,7 +67,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeTruthy();
|
||||
expect(authGuard.canActivate(router)).toBeTruthy();
|
||||
expect(routerService.navigate).not.toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(router)).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('Should canActivate return false if the realm_access is not present', async(() => {
|
||||
@@ -86,7 +86,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(router)).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('Should redirect to the redirectURL if canActivate is false and redirectUrl is in data', async(() => {
|
||||
@@ -97,7 +97,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
router.data = { 'roles': ['role1', 'role2'], 'redirectUrl': 'no-role-url' };
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(router)).toBeFalsy();
|
||||
expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']);
|
||||
}));
|
||||
|
||||
@@ -109,7 +109,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
|
||||
router.data = { 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(router, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(router)).toBeFalsy();
|
||||
expect(routerService.navigate).not.toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
@@ -121,7 +121,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
route.params = { appName: 'fakeapp' };
|
||||
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(route, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(route)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('Should canActivate be false if hasRealm is false and hasClientRole is true', () => {
|
||||
@@ -132,7 +132,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
route.params = { appName: 'fakeapp' };
|
||||
route.data = { 'clientRoles': ['fakeapp'], 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(route, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(route)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('Should canActivate be true if both Real Role and Client Role are present int the JWT token', () => {
|
||||
@@ -147,7 +147,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
route.params = { appName: 'fakeapp' };
|
||||
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(route, null)).toBeTruthy();
|
||||
expect(authGuard.canActivate(route)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Should canActivate be false if the Client Role is not present int the JWT token with the correct role', () => {
|
||||
@@ -162,7 +162,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
route.params = { appName: 'fakeapp' };
|
||||
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
|
||||
|
||||
expect(authGuard.canActivate(route, null)).toBeFalsy();
|
||||
expect(authGuard.canActivate(route)).toBeFalsy();
|
||||
});
|
||||
|
||||
describe('ClientRole ', () => {
|
||||
|
@@ -17,14 +17,14 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuardSsoRoleService implements CanActivate {
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||
canActivate(route: ActivatedRouteSnapshot): boolean {
|
||||
let hasRole;
|
||||
let hasRealmRole = false;
|
||||
let hasClientRole = true;
|
||||
|
@@ -66,7 +66,7 @@ export class AuthGuard extends AuthGuardBase {
|
||||
window.removeEventListener('storage', this.ticketChangeBind);
|
||||
}
|
||||
|
||||
checkLogin(activeRoute: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
|
||||
if (this.authenticationService.isLoggedIn() || this.withCredentials) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -209,7 +209,7 @@ describe('AuthenticationService', () => {
|
||||
});
|
||||
|
||||
it('[BPM] should return an BPM ticket after the login done', (done) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe((response) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(true);
|
||||
// cspell: disable-next
|
||||
expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
|
||||
@@ -247,7 +247,7 @@ describe('AuthenticationService', () => {
|
||||
|
||||
it('[BPM] should return an error when the logout return error', (done) => {
|
||||
authService.logout().subscribe(
|
||||
(res) => {
|
||||
() => {
|
||||
},
|
||||
(err: any) => {
|
||||
expect(err).toBeDefined();
|
||||
@@ -344,9 +344,8 @@ describe('AuthenticationService', () => {
|
||||
|
||||
it('[ECM] should not save the remember me cookie after failed login', (done) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
|
||||
(res) => {
|
||||
},
|
||||
(err: any) => {
|
||||
() => {},
|
||||
() => {
|
||||
expect(cookie['ALFRESCO_REMEMBER_ME']).toBeUndefined();
|
||||
disposableLogin.unsubscribe();
|
||||
done();
|
||||
@@ -401,9 +400,8 @@ describe('AuthenticationService', () => {
|
||||
|
||||
it('[ALL] should return login fail if only ECM call fail', (done) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
|
||||
(res) => {
|
||||
},
|
||||
(err: any) => {
|
||||
() => {},
|
||||
() => {
|
||||
expect(authService.isLoggedIn()).toBe(false, 'isLoggedIn');
|
||||
expect(authService.getTicketEcm()).toBe(null, 'getTicketEcm');
|
||||
// cspell: disable-next
|
||||
@@ -424,9 +422,8 @@ describe('AuthenticationService', () => {
|
||||
|
||||
it('[ALL] should return login fail if only BPM call fail', (done) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
|
||||
(res) => {
|
||||
},
|
||||
(err: any) => {
|
||||
() => {},
|
||||
() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
@@ -448,9 +445,8 @@ describe('AuthenticationService', () => {
|
||||
|
||||
it('[ALL] should return ticket undefined when the credentials are wrong', (done) => {
|
||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
|
||||
(res) => {
|
||||
},
|
||||
(err: any) => {
|
||||
() => {},
|
||||
() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
|
@@ -179,7 +179,7 @@ describe('Log Service', () => {
|
||||
appConfigService.config['logLevel'] = 'trace';
|
||||
providesLogComponent = TestBed.createComponent(ProvidesLogComponent);
|
||||
|
||||
providesLogComponent.componentInstance.logService.onMessage.subscribe((message) => {
|
||||
providesLogComponent.componentInstance.logService.onMessage.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -89,7 +89,7 @@ describe('RenditionsService', () => {
|
||||
});
|
||||
|
||||
it('Create rendition service should call the server with the ID passed and the asked encoding', (done) => {
|
||||
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
||||
service.createRendition('fake-node-id', 'pdf').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||
done();
|
||||
@@ -114,8 +114,8 @@ describe('RenditionsService', () => {
|
||||
});
|
||||
|
||||
it('Get rendition service should catch the error', (done) => {
|
||||
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
||||
}, (res) => {
|
||||
service.getRenditionsListByNodeId('fake-node-id').subscribe(() => {
|
||||
}, () => {
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@@ -63,7 +63,7 @@ export class SharedLinksApiService {
|
||||
* @returns The shared link just created
|
||||
*/
|
||||
createSharedLinks(nodeId: string, options: any = {}): Observable<SharedLinkEntry> {
|
||||
const promise = this.sharedLinksApi.addSharedLink({ nodeId: nodeId });
|
||||
const promise = this.sharedLinksApi.addSharedLink({ nodeId: nodeId }, options);
|
||||
|
||||
return from(promise).pipe(
|
||||
catchError((err) => of(err))
|
||||
|
@@ -158,7 +158,7 @@ export class TranslateLoaderService implements TranslateLoader {
|
||||
observer.complete();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
() => {
|
||||
observer.error('Failed to load some resources');
|
||||
});
|
||||
} else {
|
||||
|
@@ -222,8 +222,7 @@ export class UploadService {
|
||||
emitter.emit({ value: data });
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
});
|
||||
.catch(() => {});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
Reference in New Issue
Block a user