mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
#1281 Cannot login after logging out
This commit is contained in:
parent
48fa09c56e
commit
03f805a804
@ -144,6 +144,32 @@ describe('AlfrescoAuthentication', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('ticket should be deleted only after logout request is accepted', (done) => {
|
||||
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
let logoutPromise = authService.logout();
|
||||
|
||||
expect(authService.getTicketEcm()).toBe('fake-post-ticket');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 204
|
||||
});
|
||||
|
||||
logoutPromise.subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 201,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false if the user is not logged in', () => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||
@ -200,6 +226,30 @@ describe('AlfrescoAuthentication', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('ticket should be deleted only after logout request is accepted', (done) => {
|
||||
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
let logoutPromise = authService.logout();
|
||||
|
||||
expect(authService.getTicketBpm()).toBe('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200
|
||||
});
|
||||
|
||||
logoutPromise.subscribe(() => {
|
||||
expect(authService.isLoggedIn()).toBe(false);
|
||||
expect(authService.isBpmLoggedIn()).toBe(false);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 200
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a ticket undefined after logout', (done) => {
|
||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||
authService.logout().subscribe(() => {
|
||||
|
@ -114,10 +114,10 @@ export class AlfrescoAuthenticationService {
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
public logout() {
|
||||
this.removeTicket();
|
||||
return Observable.fromPromise(this.callApiLogout())
|
||||
.map(res => <any> res)
|
||||
.do(response => {
|
||||
this.removeTicket();
|
||||
this.logoutSubject.next(response);
|
||||
return response;
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user