Skip to content

Update acceptedIssuedAt JavaDocs#471

Merged
jimmyjames merged 2 commits intomasterfrom
issued-at-docs
Feb 3, 2021
Merged

Update acceptedIssuedAt JavaDocs#471
jimmyjames merged 2 commits intomasterfrom
issued-at-docs

Conversation

@jimmyjames
Copy link
Copy Markdown
Contributor

Changes

Fixes #470.

Updates the JavaDocs of acceptIssuedAt to clarify the behavior if used in combination with ignoreIssuedAt.

Also fixes the related test; it was not passing the mocked clock, and the mocked clock and issuedAt leeway was configured to always pass. This was masking any issues with ignoreIssuedAt, since the validation would pass if the issuedAt claim was not ignored.

Checklist

@jimmyjames jimmyjames added documentation This adds, fixes or improves documentation review:small Small review labels Feb 1, 2021
@jimmyjames jimmyjames added this to the v3-Next milestone Feb 1, 2021
@jimmyjames jimmyjames requested a review from a team as a code owner February 1, 2021 17:48
guo-hong
guo-hong previously approved these changes Feb 1, 2021
Copy link
Copy Markdown

@guo-hong guo-hong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

* If Issued At verification has been disabled with {@link #ignoreIssuedAt()}, no verification of the Issued At
* claim will be performed, and this method has no effect.
*
* Issued At Date is verified by default when the value is present, unless disabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line below looks similar to this one. We should keep one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I pushed a new commit to remove the duplication and improve clarity.

public void shouldOverrideAcceptIssuedAtWhenIgnoreIssuedAtFlagPassedAndSkipTheVerification() throws Exception {
Clock clock = mock(Clock.class);
when(clock.getToday()).thenReturn(new Date(DATE_TOKEN_MS_VALUE - 1000));
when(clock.getToday()).thenReturn(new Date(DATE_TOKEN_MS_VALUE - 10000));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly the issue with this test was the mocked clock not being passed. Given the logic didn't change, can we roll back this, or why is it introduced? If you look at the rest of the tests they are all adding/subtracting 1000 (1 seg) to this date constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the test I understand it, is to verify that if using a custom issuedAt leeway that would cause verification to fail, when calling ignoreIssuedAt the verification would still pass. If setting the mock clock to return one second earlier (subtracting 1000), the verification would still pass if not using ignoreIssuedAt, unless setting the leeway to zero. That means the test would pass even if ignoredIssuedAt were not actually ignoring the issuedAt validation. For context:

  • JWT issuedAt date: Sat Jan 17 20:26:32 CST 1970
  • Setting mock clock to DEFAULT_TOKEN_MS_VALUE - 1000): Sat Jan 17 20:26:31 CST 1970 (1 second before issuedAt date)
  • Setting mock clock to DEFAULT_TOKEN_MS_VALUE - 10000): Sat Jan 17 20:26:22 CST 1970 (10 seconds before issuedAt date)

@jimmyjames jimmyjames merged commit 32043cd into master Feb 3, 2021
@jimmyjames jimmyjames deleted the issued-at-docs branch February 3, 2021 22:36
@jimmyjames jimmyjames modified the milestones: v3-Next, 3.13.0 Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This adds, fixes or improves documentation review:small Small review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update documentation for acceptIssuedAt

3 participants