Skip to content

Commit ff484ac

Browse files
authored
Merge pull request #54 from forivall/invalid-body-test
Test for invalid JSON in body
2 parents a915ffc + f9a9948 commit ff484ac

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/jws.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ test('jws.decode: with a bogus header ', function (t) {
291291
t.end();
292292
});
293293

294+
test('jws.decode: with invalid json in body', function (t) {
295+
const header = Buffer('{"alg":"HS256","typ":"JWT"}').toString('base64');
296+
const payload = Buffer('sup').toString('base64');
297+
const sig = header + '.' + payload + '.';
298+
var parts;
299+
t.throws(function () {
300+
parts = jws.decode(sig);
301+
})
302+
t.end();
303+
});
304+
294305
test('jws.verify: missing or invalid algorithm', function (t) {
295306
const header = Buffer('{"something":"not an algo"}').toString('base64');
296307
const payload = Buffer('sup').toString('base64');

0 commit comments

Comments
 (0)