Skip to content

-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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrewnester
Copy link
Contributor

Fixes #500

@andrewnester
Copy link
Contributor Author

@MitMaro @ziluvatar may I ask you to review this change?

Copy link
Contributor

@MitMaro MitMaro left a 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. :)

it('should throw exception when given -Infinity', function () {
expect(() => signWithExpiresIn({exp: -Infinity})).to.throw(
'"exp" should be a number of seconds'
);
Copy link
Contributor

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.

it('should throw exception when given Infinity', function () {
expect(() => signWithExpiresIn({exp: Infinity})).to.throw(
'"exp" should be a number of seconds'
);
Copy link
Contributor

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.

it('should throw exception when given NaN', function () {
expect(() => signWithExpiresIn({exp: NaN})).to.throw(
'"exp" should be a number of seconds'
);
Copy link
Contributor

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.

expect(() => signWithIssueAtSync({iat: NaN})).to.throw(
'"iat" should be a number of seconds'
);
});
Copy link
Contributor

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.

it('should throw exception when given -Infinity', function () {
expect(() => signWithNotBefore({nbf: -Infinity})).to.throw(
'"nbf" should be a number of seconds'
);
Copy link
Contributor

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.

@andrewnester
Copy link
Contributor Author

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants