Skip to content

Commit 7a8832b

Browse files
committed
update login route test
1 parent 2835f95 commit 7a8832b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/modules/login/routes.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const Hapi = require('hapi');
3+
const Jwt = require('jsonwebtoken');
34
const { expect } = require('code');
45
const {
56
describe,
@@ -20,6 +21,10 @@ const AuthAttempt = require('./auth-attempt');
2021

2122
const Login = require('./routes');
2223

24+
const Config = require('../../../config');
25+
26+
const { secret, algorithm } = Config.get('/jwt');
27+
2328
let server;
2429

2530
before(async () => {
@@ -103,6 +108,13 @@ describe('POST /login', () => {
103108
expect(response.statusCode).to.equal(200);
104109
expect(response.result).to.be.an.object();
105110
expect(response.result.authorization).to.be.a.string();
111+
112+
const decoded = Jwt.verify(response.result.authorization, secret, { algorithms: [algorithm] });
113+
114+
expect(decoded.scope).to.be.a.array();
115+
expect(decoded.roles).to.be.a.object();
116+
expect(decoded.session).to.be.a.object();
117+
expect(decoded.user).to.be.a.object();
106118
});
107119
});
108120

0 commit comments

Comments
 (0)