Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sambego committed Aug 23, 2019
1 parent 3fceb9d commit cbc840b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/unit/editor/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ describe('JWT', function() {

it('considers Base64 (not URL) encoded tokens invalid', function() {
const token = b64u.toBase64(tokens.hs256.token);

jwt.isToken(token).should.be.false;
return jwt.verify(token, tokens.hs256.secret).should.eventually.include({validBase64: false});
return jwt.verify(token, tokens.hs256.secret).should.eventually.include({validSignature: false});
});

describe('verifies valid tokens', function() {
Expand Down Expand Up @@ -94,10 +93,10 @@ describe('JWT', function() {
promises.push(jwt.verify(token3 + '.', 'whatever'));
promises.push(jwt.verify(token3 + '.' + split[2], 'whatever'));

return Promise.all(promises.map(p => p.then(v => !v, e => true)))
return Promise.all(promises.map(p => p.then(v => !v.validSignature, e => true)))
.then(all => all.every(v => v))
.finally(() => log.enableAll())
.should.eventually.include({validSignature: true});
.should.eventually.be.true;
});

it('signs/verifies tokens (HS256)', function() {
Expand Down Expand Up @@ -227,7 +226,7 @@ describe('JWT', function() {
it('fails on invalid Base64 and Base64 URL strings', function() {
data.forEach(d => {
if(d.b64.match(/[\+\/=]/)) {
jwt.isValidBase64String(d.b64, true).should.be.false;
jwt.isValidBase64String(d.b64).should.be.false;
}
});
});
Expand Down

0 comments on commit cbc840b

Please sign in to comment.