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:
parent
cbebe2b003
commit
b941da93e1
24
test/api.js
24
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', () => {
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user