Переглянути джерело

Add auth logout tests

production
Jack Foltz 5 роки тому
джерело
коміт
b941da93e1
Підписано: foltik <jack@foltz.io> Ідентифікатор GPG ключа: 303F88F996E95541
1 змінених файлів з 24 додано та 0 видалено
  1. +24
    -0
      test/api.js

+ 24
- 0
test/api.js Переглянути файл

@@ -187,6 +187,30 @@ describe('Authentication', () => {
});
});

describe('/POST logout', () => {
async function verifyNoSession() {
const res = await util.whoami(agent);
util.verifyResponse(res, 401, 'Unauthorized.');
}

describe('0 Valid Request', () => {
it('must logout a user with a session', async () => {
await util.createTestSession(agent);
const res = await util.logout(agent);
util.verifyResponse(res, 200, 'Logged out.');
return verifyNoSession();
});
});

describe('1 Invalid Session', () => {
it('must not logout a user without a session', async () => {
const res = await util.logout(agent);
util.verifyResponse(res, 400, 'Not logged in.');
return verifyNoSession();
});
});
});

describe('/POST whoami', () => {
function verifyWhoami(res, username, displayname, scope, key) {
res.should.have.status(200);


Завантаження…
Відмінити
Зберегти