|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const jwt = require('../'); |
| 4 | +const expect = require('chai').expect; |
| 5 | +const testUtils = require('./test-utils') |
| 6 | + |
| 7 | +describe('nonce and nonce_supported option', function () { |
| 8 | + |
| 9 | + [ |
| 10 | + { |
| 11 | + description: 'should succeed without nonce and without nonce support', |
| 12 | + signParam: { nonce_supported: false }, |
| 13 | + verifyParam: { }, |
| 14 | + }, |
| 15 | + { |
| 16 | + description: 'should succeed without nonce but with nonce support', |
| 17 | + signParam: { nonce_supported: true }, |
| 18 | + verifyParam: { }, |
| 19 | + }, |
| 20 | + { |
| 21 | + description: 'should succeed with nonce but without nonce support', |
| 22 | + signParam: { nonce_supported: false }, |
| 23 | + verifyParam: { nonce: 'abcde' }, |
| 24 | + }, |
| 25 | + { |
| 26 | + description: 'should succeed with nonce and nonce support', |
| 27 | + signParam: { nonce: 'abcde', nonce_supported: true }, |
| 28 | + verifyParam: { nonce: 'abcde' }, |
| 29 | + }, |
| 30 | + ].forEach((testCase) => { |
| 31 | + it(testCase.description, function (done) { |
| 32 | + var token = jwt.sign(testCase.signParam, undefined, { algorithm: 'none' }); |
| 33 | + testUtils.verifyJWTHelper(token, undefined, testCase.verifyParam, (err) => { |
| 34 | + testUtils.asyncCheck(done, () => { |
| 35 | + expect(err).to.be.null; |
| 36 | + }); |
| 37 | + }); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | +}); |
0 commit comments