-
Notifications
You must be signed in to change notification settings - Fork 1.2k
-Infinity, Infinity and NaN should fail validation #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@MitMaro @ziluvatar may I ask you to review this change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
It may take a while to get this merged since it's technically a breaking change. But that's up to @ziluvatar , as I'm just a contributor like you. :)
test/claim-exp.test.js
Outdated
it('should throw exception when given -Infinity', function () { | ||
expect(() => signWithExpiresIn({exp: -Infinity})).to.throw( | ||
'"exp" should be a number of seconds' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case can be moved into the array in the 'jwt.sign "exp" claim validation'
block.
test/claim-exp.test.js
Outdated
it('should throw exception when given Infinity', function () { | ||
expect(() => signWithExpiresIn({exp: Infinity})).to.throw( | ||
'"exp" should be a number of seconds' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto to the above comment, this test case can be moved into the array in the '
jwt.sign "exp" claim validation'
block.
test/claim-exp.test.js
Outdated
it('should throw exception when given NaN', function () { | ||
expect(() => signWithExpiresIn({exp: NaN})).to.throw( | ||
'"exp" should be a number of seconds' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, this test case can be moved into the array in the 'jwt.sign "exp" claim validation'
block.
test/claim-iat.test.js
Outdated
expect(() => signWithIssueAtSync({iat: NaN})).to.throw( | ||
'"iat" should be a number of seconds' | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test can be moved to the array above in the 'jwt.sign "iat" claim validation'
block.
test/claim-nbf.test.js
Outdated
it('should throw exception when given -Infinity', function () { | ||
expect(() => signWithNotBefore({nbf: -Infinity})).to.throw( | ||
'"nbf" should be a number of seconds' | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the previous comments, this might not be a surprise. This and the following tests can be moved into the jwt.sign "nbf" claim validation
block above.
@MitMaro thanks a lot for your comments, I updated tests and resolved existing merge conflicts. As to change itself, yes, I understand that it's quite BC but anyway that something that should be done, so I am fine if it takes a bit longer :) |
Fixes #500