Merge pull request #823 from Alfresco/dev-valbano-fix-818

Dev valbano fix 818
This commit is contained in:
Denys Vuika 2016-09-27 15:31:38 +01:00 committed by GitHub
commit 976432c883
2 changed files with 32 additions and 2 deletions

View File

@ -84,6 +84,21 @@ describe('AlfrescoAuthentication', () => {
});
});
it('should save only ECM ticket on localStorage', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
expect(authService.isLoggedIn()).toBe(true);
expect(authService.getTicketBpm()).toBeNull();
expect(authService.getAlfrescoApi().bpmAuth.isLoggedIn()).toBeFalsy();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
});
});
it('should return ticket undefined when the credentials are wrong', (done) => {
authService.login('fake-wrong-username', 'fake-wrong-password').subscribe(
(res) => {
@ -164,6 +179,21 @@ describe('AlfrescoAuthentication', () => {
});
});
it('should save only BPM ticket on localStorage', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
expect(authService.isLoggedIn()).toBe(true);
expect(authService.getTicketEcm()).toBeNull();
expect(authService.getAlfrescoApi().ecmAuth.isLoggedIn()).toBeFalsy();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
});
});
it('should return ticket undefined when the credentials are wrong', (done) => {
authService.login('fake-wrong-username', 'fake-wrong-password').subscribe(
(res) => {

View File

@ -177,7 +177,7 @@ export class AlfrescoAuthenticationService {
* The method save the ECM ticket in the localStorage
*/
public saveTicketEcm(): void {
if (this.alfrescoApi) {
if (this.alfrescoApi && this.alfrescoApi.getTicketEcm()) {
localStorage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
}
}
@ -186,7 +186,7 @@ export class AlfrescoAuthenticationService {
* The method save the BPM ticket in the localStorage
*/
public saveTicketBpm(): void {
if (this.alfrescoApi) {
if (this.alfrescoApi && this.alfrescoApi.getTicketBpm()) {
localStorage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
}
}