diff options
Diffstat (limited to 'test/js/third_party/jsonwebtoken/issue_304.test.js')
-rw-r--r-- | test/js/third_party/jsonwebtoken/issue_304.test.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/js/third_party/jsonwebtoken/issue_304.test.js b/test/js/third_party/jsonwebtoken/issue_304.test.js new file mode 100644 index 000000000..257bcc09d --- /dev/null +++ b/test/js/third_party/jsonwebtoken/issue_304.test.js @@ -0,0 +1,43 @@ +import jwt from "jsonwebtoken"; +import { describe, it, expect } from "bun:test"; + +describe("issue 304 - verifying values other than strings", function () { + it("should fail with numbers", function (done) { + jwt.verify(123, "foo", function (err) { + expect(err.name).toEqual("JsonWebTokenError"); + done(); + }); + }); + + it("should fail with objects", function (done) { + jwt.verify({ foo: "bar" }, "biz", function (err) { + expect(err.name).toEqual("JsonWebTokenError"); + done(); + }); + }); + + it("should fail with arrays", function (done) { + jwt.verify(["foo"], "bar", function (err) { + expect(err.name).toEqual("JsonWebTokenError"); + done(); + }); + }); + + it("should fail with functions", function (done) { + jwt.verify( + function () {}, + "foo", + function (err) { + expect(err.name).toEqual("JsonWebTokenError"); + done(); + }, + ); + }); + + it("should fail with booleans", function (done) { + jwt.verify(true, "foo", function (err) { + expect(err.name).toEqual("JsonWebTokenError"); + done(); + }); + }); +}); |