mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
AAE-30882 - Fixed unit test for js-api
This commit is contained in:
@@ -48,20 +48,20 @@ describe('Ecm Auth test', () => {
|
|||||||
assert.equal(auth.authentications.basicAuth.username, 'johndoe');
|
assert.equal(auth.authentications.basicAuth.username, 'johndoe');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should forget username on logout', (done) => {
|
it('should forget username on logout', async () => {
|
||||||
const auth = new ContentAuth({}, alfrescoJsApi);
|
const auth = new ContentAuth({}, alfrescoJsApi);
|
||||||
|
|
||||||
authEcmMock.get201Response();
|
authEcmMock.get201ResponseJohnDoe();
|
||||||
|
|
||||||
auth.login('johndoe', 'password');
|
await auth.login('johndoe', 'password');
|
||||||
assert.equal(auth.authentications.basicAuth.username, 'johndoe');
|
assert.equal(auth.authentications.basicAuth.username, 'ROLE_TICKET');
|
||||||
|
assert.equal(auth.storage.getItem('ACS_USERNAME'), 'johndoe');
|
||||||
|
|
||||||
authEcmMock.get204ResponseLogout();
|
authEcmMock.get204ResponseLogout();
|
||||||
|
|
||||||
auth.logout().then(() => {
|
await auth.logout();
|
||||||
assert.equal(auth.authentications.basicAuth.username, null);
|
assert.equal(auth.authentications.basicAuth.username, null);
|
||||||
done();
|
assert.equal(auth.storage.getItem('ACS_USERNAME'), '');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('With Authentication', () => {
|
describe('With Authentication', () => {
|
||||||
|
@@ -44,6 +44,22 @@ export class EcmAuthMock extends BaseMock {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get201ResponseJohnDoe(forceTicket?: string): void {
|
||||||
|
const returnMockTicket = forceTicket || 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1';
|
||||||
|
|
||||||
|
this.createNockWithCors()
|
||||||
|
.post('/alfresco/api/-default-/public/authentication/versions/1/tickets', {
|
||||||
|
userId: 'johndoe',
|
||||||
|
password: 'password'
|
||||||
|
})
|
||||||
|
.reply(201, {
|
||||||
|
entry: {
|
||||||
|
id: returnMockTicket,
|
||||||
|
userId: 'johndoe'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get200ValidTicket(forceTicket?: string): void {
|
get200ValidTicket(forceTicket?: string): void {
|
||||||
const returnMockTicket = forceTicket || 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1';
|
const returnMockTicket = forceTicket || 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user