diff --git a/test/claim-aud.test.js b/test/claim-aud.test.js index 448da5c..0e7a6dc 100644 --- a/test/claim-aud.test.js +++ b/test/claim-aud.test.js @@ -33,9 +33,9 @@ describe('audience', function() { Infinity, NaN, {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((audience) => { - it(`should error with with value ${util.inspect(audience)}`, function (done) { + it(`should error with value ${util.inspect(audience)}`, function (done) { signWithAudience(audience, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -45,16 +45,6 @@ describe('audience', function() { }); }); - // undefined needs special treatment because {} is not the same as {aud: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, 'secret', {audience: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property('message', '"audience" must be a string or array'); - }); - }); - }); - it('should error when "aud" is in payload', function (done) { signWithAudience('my_aud', {aud: ''}, (err) => { testUtils.asyncCheck(done, () => { diff --git a/test/claim-exp.test.js b/test/claim-exp.test.js index 94360f6..200f536 100644 --- a/test/claim-exp.test.js +++ b/test/claim-exp.test.js @@ -34,9 +34,9 @@ describe('expires', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((expiresIn) => { - it(`should error with with value ${util.inspect(expiresIn)}`, function (done) { + it(`should error with value ${util.inspect(expiresIn)}`, function (done) { signWithExpiresIn(expiresIn, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -47,19 +47,6 @@ describe('expires', function() { }); }); - // undefined needs special treatment because {} is not the same as {expiresIn: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {expiresIn: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property( - 'message', - '"expiresIn" should be a number of seconds or string representing a timespan' - ); - }); - }); - }); - it ('should error when "exp" is in payload', function(done) { signWithExpiresIn(100, {exp: 100}, (err) => { testUtils.asyncCheck(done, () => { @@ -96,16 +83,15 @@ describe('expires', function() { true, false, null, - undefined, '', ' ', 'invalid', [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((exp) => { - it(`should error with with value ${util.inspect(exp)}`, function (done) { + it(`should error with value ${util.inspect(exp)}`, function (done) { signWithExpiresIn(undefined, {exp}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -130,9 +116,9 @@ describe('expires', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((exp) => { - it(`should error with with value ${util.inspect(exp)}`, function (done) { + it(`should error with value ${util.inspect(exp)}`, function (done) { const encodedPayload = base64UrlEncode(JSON.stringify({exp})); const token = `${noneAlgorithmHeader}.${encodedPayload}.`; testUtils.verifyJWTHelper(token, undefined, {exp}, (err) => { diff --git a/test/claim-iat.test.js b/test/claim-iat.test.js index 5bf8df7..3072aaf 100644 --- a/test/claim-iat.test.js +++ b/test/claim-iat.test.js @@ -36,7 +36,7 @@ describe('issue at', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((iat) => { it(`should error with iat of ${util.inspect(iat)}`, function (done) { signWithIssueAt(iat, {}, (err) => { @@ -47,16 +47,6 @@ describe('issue at', function() { }); }); }); - - // undefined needs special treatment because {} is not the same as {iat: undefined} - it('should error with iat of undefined', function (done) { - testUtils.signJWTHelper({iat: undefined}, 'secret', {algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err.message).to.equal('"iat" should be a number of seconds'); - }); - }); - }); }); describe('"iat" in payload with "maxAge" option validation', function () { diff --git a/test/claim-iss.test.js b/test/claim-iss.test.js index ec82102..cf33c1a 100644 --- a/test/claim-iss.test.js +++ b/test/claim-iss.test.js @@ -30,9 +30,9 @@ describe('issuer', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((issuer) => { - it(`should error with with value ${util.inspect(issuer)}`, function (done) { + it(`should error with value ${util.inspect(issuer)}`, function (done) { signWithIssuer(issuer, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -42,16 +42,6 @@ describe('issuer', function() { }); }); - // undefined needs special treatment because {} is not the same as {issuer: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {issuer: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property('message', '"issuer" must be a string'); - }); - }); - }); - it('should error when "iss" is in payload', function (done) { signWithIssuer('foo', {iss: 'bar'}, (err) => { testUtils.asyncCheck(done, () => { diff --git a/test/claim-jti.test.js b/test/claim-jti.test.js index a10a9b5..e1cfba8 100644 --- a/test/claim-jti.test.js +++ b/test/claim-jti.test.js @@ -30,9 +30,9 @@ describe('jwtid', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((jwtid) => { - it(`should error with with value ${util.inspect(jwtid)}`, function (done) { + it(`should error with value ${util.inspect(jwtid)}`, function (done) { signWithJWTId(jwtid, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -42,16 +42,6 @@ describe('jwtid', function() { }); }); - // undefined needs special treatment because {} is not the same as {jwtid: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {jwtid: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property('message', '"jwtid" must be a string'); - }); - }); - }); - it('should error when "jti" is in payload', function (done) { signWithJWTId('foo', {jti: 'bar'}, (err) => { testUtils.asyncCheck(done, () => { diff --git a/test/claim-nbf.test.js b/test/claim-nbf.test.js index 1aa5cda..8f89508 100644 --- a/test/claim-nbf.test.js +++ b/test/claim-nbf.test.js @@ -34,9 +34,9 @@ describe('not before', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((notBefore) => { - it(`should error with with value ${util.inspect(notBefore)}`, function (done) { + it(`should error with value ${util.inspect(notBefore)}`, function (done) { signWithNotBefore(notBefore, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -47,19 +47,6 @@ describe('not before', function() { }); }); - // undefined needs special treatment because {} is not the same as {notBefore: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {notBefore: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property( - 'message', - '"notBefore" should be a number of seconds or string representing a timespan' - ); - }); - }); - }); - it('should error when "nbf" is in payload', function (done) { signWithNotBefore(100, {nbf: 100}, (err) => { testUtils.asyncCheck(done, () => { @@ -96,7 +83,6 @@ describe('not before', function() { true, false, null, - undefined, '', ' ', 'invalid', @@ -105,7 +91,7 @@ describe('not before', function() { {}, {foo: 'bar'}, ].forEach((nbf) => { - it(`should error with with value ${util.inspect(nbf)}`, function (done) { + it(`should error with value ${util.inspect(nbf)}`, function (done) { signWithNotBefore(undefined, {nbf}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -132,7 +118,7 @@ describe('not before', function() { {}, {foo: 'bar'}, ].forEach((nbf) => { - it(`should error with with value ${util.inspect(nbf)}`, function (done) { + it(`should error with value ${util.inspect(nbf)}`, function (done) { const encodedPayload = base64UrlEncode(JSON.stringify({nbf})); const token = `${noneAlgorithmHeader}.${encodedPayload}.`; testUtils.verifyJWTHelper(token, undefined, {nbf}, (err) => { diff --git a/test/claim-private.tests.js b/test/claim-private.tests.js index d21a720..b512f40 100644 --- a/test/claim-private.tests.js +++ b/test/claim-private.tests.js @@ -24,7 +24,7 @@ describe('with a private claim', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((privateClaim) => { it(`should sign and verify with claim of ${util.inspect(privateClaim)}`, function (done) { signWithPayload({privateClaim}, (e1, token) => { @@ -43,7 +43,7 @@ describe('with a private claim', function() { [ -Infinity, Infinity, - NaN, + NaN ].forEach((privateClaim) => { it(`should sign and verify with claim of ${util.inspect(privateClaim)}`, function (done) { signWithPayload({privateClaim}, (e1, token) => { diff --git a/test/claim-sub.tests.js b/test/claim-sub.tests.js index 5cd3379..4366623 100644 --- a/test/claim-sub.tests.js +++ b/test/claim-sub.tests.js @@ -30,9 +30,9 @@ describe('subject', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((subject) => { - it(`should error with with value ${util.inspect(subject)}`, function (done) { + it(`should error with value ${util.inspect(subject)}`, function (done) { signWithSubject(subject, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -42,16 +42,6 @@ describe('subject', function() { }); }); - // undefined needs special treatment because {} is not the same as {subject: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {subject: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property('message', '"subject" must be a string'); - }); - }); - }); - it('should error when "sub" is in payload', function (done) { signWithSubject('foo', {sub: 'bar'}, (err) => { testUtils.asyncCheck(done, () => { diff --git a/test/header-kid.test.js b/test/header-kid.test.js index 42633ad..58ae4ca 100644 --- a/test/header-kid.test.js +++ b/test/header-kid.test.js @@ -30,9 +30,9 @@ describe('keyid', function() { [], ['foo'], {}, - {foo: 'bar'}, + {foo: 'bar'} ].forEach((keyid) => { - it(`should error with with value ${util.inspect(keyid)}`, function (done) { + it(`should error with value ${util.inspect(keyid)}`, function (done) { signWithKeyId(keyid, {}, (err) => { testUtils.asyncCheck(done, () => { expect(err).to.be.instanceOf(Error); @@ -41,16 +41,6 @@ describe('keyid', function() { }); }); }); - - // undefined needs special treatment because {} is not the same as {keyid: undefined} - it('should error with with value undefined', function (done) { - testUtils.signJWTHelper({}, undefined, {keyid: undefined, algorithm: 'none'}, (err) => { - testUtils.asyncCheck(done, () => { - expect(err).to.be.instanceOf(Error); - expect(err).to.have.property('message', '"keyid" must be a string'); - }); - }); - }); }); describe('when signing a token', function () {