1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-02-26 00:55:20 -05:00

Add auth logout tests

This commit is contained in:
Jack Foltz 2018-08-13 05:59:04 -04:00
parent cbebe2b003
commit b941da93e1
Signed by: foltik
GPG Key ID: 303F88F996E95541

View File

@ -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', () => { describe('/POST whoami', () => {
function verifyWhoami(res, username, displayname, scope, key) { function verifyWhoami(res, username, displayname, scope, key) {
res.should.have.status(200); res.should.have.status(200);