-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling non string tokens (#305)
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var jwt = require('../index'); | ||
var expect = require('chai').expect; | ||
|
||
describe('issue 304 - verifying values other than strings', function() { | ||
|
||
it('should fail with numbers', function (done) { | ||
jwt.verify(123, 'foo', function (err, decoded) { | ||
expect(err.name).to.equal('JsonWebTokenError'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail with objects', function (done) { | ||
jwt.verify({ foo: 'bar' }, 'biz', function (err, decoded) { | ||
expect(err.name).to.equal('JsonWebTokenError'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail with arrays', function (done) { | ||
jwt.verify(['foo'], 'bar', function (err, decoded) { | ||
expect(err.name).to.equal('JsonWebTokenError'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail with functions', function (done) { | ||
jwt.verify(function() {}, 'foo', function (err, decoded) { | ||
expect(err.name).to.equal('JsonWebTokenError'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail with booleans', function (done) { | ||
jwt.verify(true, 'foo', function (err, decoded) { | ||
expect(err.name).to.equal('JsonWebTokenError'); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters