add tests for specialized exceptions
This commit is contained in:
parent
167e26117a
commit
0d782e91c5
@ -27,9 +27,12 @@ async function start_server () {
|
||||
return user;
|
||||
|
||||
return null;
|
||||
}));
|
||||
}, [
|
||||
/noauthreg/u,
|
||||
{ method: 'POST', regex: /noauthobj/u }
|
||||
]));
|
||||
|
||||
app.get ('/', (req, res) => {
|
||||
app.use ((req, res) => {
|
||||
res.status (consts.http.status_ok)
|
||||
.end ('foo');
|
||||
});
|
||||
|
@ -29,10 +29,35 @@ test ('login', async (t) => {
|
||||
|
||||
const resp = await fetch ('http://localhost:3000', { headers: { session } });
|
||||
|
||||
t.is (await resp.status, consts.http.status_ok);
|
||||
t.is (resp.status, consts.http.status_ok);
|
||||
t.is (await resp.text (), 'foo');
|
||||
});
|
||||
|
||||
test ('allow access to excluded paths', async (t) => {
|
||||
const resp = await fetch ('http://localhost:3000/noauthreg');
|
||||
|
||||
t.is (resp.status, consts.http.status_ok);
|
||||
t.is (await resp.text (), 'foo');
|
||||
});
|
||||
|
||||
test ('allow access to excluded paths with correct method', async (t) => {
|
||||
const resp = await fetch (
|
||||
'http://localhost:3000/noauthobj',
|
||||
{ method: 'POST' }
|
||||
);
|
||||
|
||||
t.is (resp.status, consts.http.status_ok);
|
||||
t.is (await resp.text (), 'foo');
|
||||
});
|
||||
|
||||
test ('reject access to excluded paths with wrong method', async (t) => {
|
||||
const resp = await fetch (
|
||||
'http://localhost:3000/noauthobj'
|
||||
);
|
||||
|
||||
t.is (resp.status, consts.http.status_unauthorized);
|
||||
});
|
||||
|
||||
test ('reject invalid user', async (t) => {
|
||||
await t.throwsAsync (client.login (
|
||||
'foo',
|
||||
|
Loading…
x
Reference in New Issue
Block a user