|
| 1 | +var jwt = require('../index'); |
| 2 | +var expect = require('chai').expect; |
| 3 | + |
| 4 | +describe('issue 304 - verifying values other than strings', function() { |
| 5 | + |
| 6 | + it('should fail with numbers', function (done) { |
| 7 | + jwt.verify(123, 'foo', function (err, decoded) { |
| 8 | + expect(err.name).to.equal('JsonWebTokenError'); |
| 9 | + done(); |
| 10 | + }); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should fail with objects', function (done) { |
| 14 | + jwt.verify({ foo: 'bar' }, 'biz', function (err, decoded) { |
| 15 | + expect(err.name).to.equal('JsonWebTokenError'); |
| 16 | + done(); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + it('should fail with arrays', function (done) { |
| 21 | + jwt.verify(['foo'], 'bar', function (err, decoded) { |
| 22 | + expect(err.name).to.equal('JsonWebTokenError'); |
| 23 | + done(); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should fail with functions', function (done) { |
| 28 | + jwt.verify(function() {}, 'foo', function (err, decoded) { |
| 29 | + expect(err.name).to.equal('JsonWebTokenError'); |
| 30 | + done(); |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should fail with booleans', function (done) { |
| 35 | + jwt.verify(true, 'foo', function (err, decoded) { |
| 36 | + expect(err.name).to.equal('JsonWebTokenError'); |
| 37 | + done(); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | +}); |
0 commit comments