-
Notifications
You must be signed in to change notification settings - Fork 931
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
Throw JWTDecodeException when date claim format is invalid #241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,13 +198,15 @@ public void shouldGetNullDateWhenParsingNull() throws Exception { | |
} | ||
|
||
@Test | ||
public void shouldGetNullDateWhenParsingNonNumericNode() throws Exception { | ||
public void shouldThrowWhenParsingNonNumericNode() throws Exception { | ||
exception.expect(JWTDecodeException.class); | ||
exception.expectMessage("The claim 'key' contained a non-numeric date value."); | ||
|
||
Map<String, JsonNode> tree = new HashMap<>(); | ||
TextNode node = new TextNode("123456789"); | ||
tree.put("key", node); | ||
|
||
Date date = deserializer.getDateFromSeconds(tree, "key"); | ||
assertThat(date, is(nullValue())); | ||
deserializer.getDateFromSeconds(tree, "key"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So no assertions as now caught by the exception.expect? if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. Because the ExpectedException is "none" for every method but for those in which we override it, when we run tests they expect (or don't) to fail with X exception and Y message. |
||
} | ||
|
||
@Test | ||
|
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.
So non Java person here, what is the difference here in checking for null?
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.
node
is the instance of theJsonNode
we're checking. The check is asserting that the instance of this object isnull
OR that the parsed JSON value is null. This second check wouldn't be possible if the instance isnull
as that would throw a NPE when calling some method on it.