Files
node-jsonwebtoken/test/set_headers.tests.js
T
José F. Romaniello 53c3987b3c Improved the sign method
Notable changes:

1.  `expiresInMinutes` and `expiresInSeconds` are deprecated and no longer supported.
2.  `notBeforeInMinutes` and `notBeforeInSeconds` are deprecated and no longer supported.
3.  options are properly validated.
4.  `options.expiresIn`, `options.notBefore`, `options.audience`, `options.issuer`, `options.subject` and `options.jwtid` are mutually exclusive with `payload.exp`, `payload.nbf`, `payload.aud`, `payload.iss`, `payload.sub` and `payload.jti` respectively.
5.  `options.algorithm` is properly validated.
6.  `options.headers` is renamed to `options.header`.
2016-04-27 12:40:28 -03:00

19 lines
577 B
JavaScript

var jwt = require('../index');
var expect = require('chai').expect;
describe('set header', function() {
it('should add the header', function () {
var token = jwt.sign({foo: 123}, '123', { header: { foo: 'bar' } });
var decoded = jwt.decode(token, {complete: true});
expect(decoded.header.foo).to.equal('bar');
});
it('should allow overriding header', function () {
var token = jwt.sign({foo: 123}, '123', { header: { alg: 'HS512' } });
var decoded = jwt.decode(token, {complete: true});
expect(decoded.header.alg).to.equal('HS512');
});
});