mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Added tests for user-info component
This commit is contained in:
@@ -74,6 +74,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(true);
|
||||
expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
|
||||
expect(authService.isEcmLoggedIn()).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -106,6 +107,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
(err: any) => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -141,6 +143,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
authService.logout().subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -158,6 +161,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
|
||||
it('should return false if the user is not logged in', () => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -171,6 +175,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(true);
|
||||
expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
|
||||
expect(authService.isBpmLoggedIn()).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -201,6 +206,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
(err: any) => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
expect(authService.isBpmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -214,6 +220,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
authService.logout().subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
expect(authService.isBpmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -280,6 +287,8 @@ describe('AlfrescoAuthentication', () => {
|
||||
expect(authService.isLoggedIn()).toBe(true);
|
||||
expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
|
||||
expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
|
||||
expect(authService.isBpmLoggedIn()).toBe(true);
|
||||
expect(authService.isEcmLoggedIn()).toBe(true);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -302,6 +311,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -322,6 +332,7 @@ describe('AlfrescoAuthentication', () => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
expect(authService.isBpmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -344,6 +355,8 @@ describe('AlfrescoAuthentication', () => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.getTicketEcm()).toBe(null);
|
||||
expect(authService.getTicketBpm()).toBe(null);
|
||||
expect(authService.isBpmLoggedIn()).toBe(false);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
|
@@ -82,6 +82,7 @@ export class AlfrescoAuthenticationService {
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
login(username: string, password: string): Observable<{ type: string, ticket: any }> {
|
||||
this.removeTicket();
|
||||
return Observable.fromPromise(this.callApiLogin(username, password))
|
||||
.map((response: any) => {
|
||||
this.saveTickets();
|
||||
@@ -191,6 +192,20 @@ export class AlfrescoAuthenticationService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return true if user is logged in on ecm provider
|
||||
*/
|
||||
public isEcmLoggedIn() {
|
||||
return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return true if user is logged in on bpm provider
|
||||
*/
|
||||
public isBpmLoggedIn() {
|
||||
return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* The method write the error in the console browser
|
||||
* @param error
|
||||
|
Reference in New Issue
Block a user