This commit is contained in:
@ -29,7 +29,8 @@ describe ('gateway', () => {
|
||||
server = http.createServer ((req, res) => {
|
||||
const passed_handler = () => {
|
||||
res.writeHead (200);
|
||||
res.end ('passed');
|
||||
const con = req.connection as unknown as Record<string, unknown>;
|
||||
res.end (JSON.stringify (con.auth));
|
||||
};
|
||||
g (req, res, passed_handler);
|
||||
});
|
||||
@ -60,8 +61,8 @@ describe ('gateway', () => {
|
||||
const resp = await get ({ authorization: `Bearer ${token.signature}` });
|
||||
expect (resp.statusCode)
|
||||
.toEqual (200);
|
||||
expect (resp.body)
|
||||
.toEqual ('passed');
|
||||
expect (JSON.parse (resp.body as string).token_id)
|
||||
.toEqual (token.id);
|
||||
});
|
||||
|
||||
it ('should allow a valid access token using cookies', async () => {
|
||||
@ -69,8 +70,20 @@ describe ('gateway', () => {
|
||||
const resp = await get ({ cookie: `cookie_jar=${token.signature}` });
|
||||
expect (resp.statusCode)
|
||||
.toEqual (200);
|
||||
expect (resp.body)
|
||||
.toEqual ('passed');
|
||||
expect (JSON.parse (resp.body as string).token_id)
|
||||
.toEqual (token.id);
|
||||
});
|
||||
|
||||
it ('should correctly deliver token data', async () => {
|
||||
const token = authority.sign ('access_token', 60, { data: 'foobar' });
|
||||
const resp = await get ({ authorization: `Bearer ${token.signature}` });
|
||||
expect (resp.statusCode)
|
||||
.toEqual (200);
|
||||
const body = JSON.parse (resp.body as string);
|
||||
expect (body.token_id)
|
||||
.toEqual (token.id);
|
||||
expect (body.token_data)
|
||||
.toEqual ('foobar');
|
||||
});
|
||||
|
||||
it ('should reject an outdated access token', async () => {
|
||||
|
Reference in New Issue
Block a user