1
1
const { expect } = require ( 'chai' ) ;
2
2
const sinon = require ( 'sinon' ) ;
3
3
const jose = require ( 'jose2' ) ;
4
- const { importJWK } = require ( 'jose' ) ;
4
+ const { importJWK, decodeProtectedHeader , decodeJwt } = require ( 'jose' ) ;
5
5
6
6
const JWT = require ( '../../lib/helpers/jwt' ) ;
7
7
const bootstrap = require ( '../test_helper' ) ;
@@ -372,6 +372,8 @@ describe('Pushed Request Object', () => {
372
372
it ( 'stores a request object and returns a uri' , async function ( ) {
373
373
const spy = sinon . spy ( ) ;
374
374
this . provider . once ( 'pushed_authorization_request.success' , spy ) ;
375
+ const spy2 = sinon . spy ( ) ;
376
+ this . provider . once ( 'pushed_authorization_request.saved' , spy2 ) ;
375
377
376
378
await this . agent . post ( '/request' )
377
379
. auth ( clientId , 'secret' )
@@ -390,6 +392,11 @@ describe('Pushed Request Object', () => {
390
392
} ) ;
391
393
392
394
expect ( spy ) . to . have . property ( 'calledOnce' , true ) ;
395
+ expect ( spy2 ) . to . have . property ( 'calledOnce' , true ) ;
396
+ const header = decodeProtectedHeader ( spy2 . args [ 0 ] [ 0 ] . request ) ;
397
+ expect ( header ) . to . deep . eql ( { alg : 'none' } ) ;
398
+ const payload = decodeJwt ( spy2 . args [ 0 ] [ 0 ] . request ) ;
399
+ expect ( payload ) . to . contain . keys ( [ 'aud' , 'exp' , 'iat' , 'nbf' , 'iss' ] ) ;
393
400
} ) ;
394
401
395
402
it ( 'forbids request_uri to be used' , async function ( ) {
0 commit comments