mirror of https://github.com/MaxLeiter/Drift
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
582 B
JavaScript
22 lines
582 B
JavaScript
var jwt = require('jsonwebtoken');
|
|
var assert = require('assert');
|
|
|
|
var expressjwt = require('../lib');
|
|
var UnauthorizedError = require('../lib/errors/UnauthorizedError');
|
|
|
|
describe('string tokens', function () {
|
|
var req = {};
|
|
var res = {};
|
|
|
|
it('should work with a valid string token', function() {
|
|
var secret = 'shhhhhh';
|
|
var token = jwt.sign('foo', secret);
|
|
|
|
req.headers = {};
|
|
req.headers.authorization = 'Bearer ' + token;
|
|
expressjwt({secret: secret, algorithms: ['HS256']})(req, res, function() {
|
|
assert.equal('foo', req.user);
|
|
});
|
|
});
|
|
|
|
}); |