Skip to content

Commit

Permalink
Rename method, add missing test
Browse files Browse the repository at this point in the history
(address CR comments)
  • Loading branch information
snegrus-adb committed Jul 3, 2018
1 parent 57ec6ba commit 5397c88
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ public void testAsJwt_validJwtFromSessionToken() {
@Test
public void testAsJwt_validJwtFromApiToken() {
UnverifiedJsonWebToken token = UnverifiedJsonWebToken.of(API_TOKEN);
assertValidToken(token);
assertValidApiToken(token);
}

@Test
public void testAsJwt_validJwtFromProxyToken() {
UnverifiedJsonWebToken token = UnverifiedJsonWebToken.of(PROXY_TOKEN);
assertValidToken(token);
assertValidApiToken(token);
}

@Test
public void testAsJwt_validJwtFromParsedToken() {
Optional<UnverifiedJsonWebToken> token = UnverifiedJsonWebToken.tryParse(PROXY_TOKEN.getToken());
assertValidToken(token.get());
assertValidApiToken(token.get());
}

@Test
Expand All @@ -79,6 +79,12 @@ public void invalidJwt_parseReturnsEmpty() {
assertEquals(parsedJwt, Optional.empty());
}

@Test
public void invalidJwt_parseReturnsEmpty_validStructure() {
Optional<UnverifiedJsonWebToken> parsedJwt = UnverifiedJsonWebToken.tryParse(INVALID_PAYLOAD_TOKEN.getToken());
assertEquals(parsedJwt, Optional.empty());
}

@Test
public void invalidJwt_invalidNumberOfSegments() {
try {
Expand All @@ -99,7 +105,7 @@ public void invalidJwt_invalidPayloadToken() {
}
}

private void assertValidToken(UnverifiedJsonWebToken token) {
private void assertValidApiToken(UnverifiedJsonWebToken token) {
assertEquals(USERID, token.getUnverifiedUserId());
assertEquals(Optional.empty(), token.getUnverifiedSessionId());
assertEquals(Optional.of(TOKEN_ID), token.getUnverifiedTokenId());
Expand Down

0 comments on commit 5397c88

Please sign in to comment.