1 | import * as jwt from 'jsonwebtoken';
|
2 | import * as express from 'express';
|
3 | import { expressjwt, ExpressJwtRequest } from '../src';
|
4 | import assert from 'assert';
|
5 |
|
6 |
|
7 | describe('string tokens', function () {
|
8 | const req = {} as ExpressJwtRequest<string>;
|
9 | const res = {} as express.Response;
|
10 |
|
11 | it('should work with a valid string token', function (done) {
|
12 | const secret = 'shhhhhh';
|
13 | const token = jwt.sign('foo', secret);
|
14 |
|
15 | req.headers = {};
|
16 | req.headers.authorization = 'Bearer ' + token;
|
17 | expressjwt({ secret: secret, algorithms: ['HS256'] })(req, res, function () {
|
18 | assert.equal(req.auth, 'foo');
|
19 | done();
|
20 | });
|
21 | });
|
22 |
|
23 | });
|