File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22const Hapi = require ( 'hapi' ) ;
3+ const Jwt = require ( 'jsonwebtoken' ) ;
34const { expect } = require ( 'code' ) ;
45const {
56 describe,
@@ -20,6 +21,10 @@ const AuthAttempt = require('./auth-attempt');
2021
2122const Login = require ( './routes' ) ;
2223
24+ const Config = require ( '../../../config' ) ;
25+
26+ const { secret, algorithm } = Config . get ( '/jwt' ) ;
27+
2328let server ;
2429
2530before ( 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
You can’t perform that action at this time.
0 commit comments