use of com.nike.cerberus.jwt.CerberusJwtClaims in project cerberus by Nike-Inc.
the class JwtServiceTest method test_generate_jwt_token_parse_and_validate_claim.
@Test
public void test_generate_jwt_token_parse_and_validate_claim() throws AuthTokenTooLongException {
String token = jwtService.generateJwtToken(cerberusJwtClaims);
assertEquals(3, token.split("\\.").length);
Optional<CerberusJwtClaims> cerberusJwtClaimsOptional = jwtService.parseAndValidateToken(token);
assertTrue(cerberusJwtClaimsOptional.isPresent());
CerberusJwtClaims cerberusJwtClaims = cerberusJwtClaimsOptional.get();
assertEquals("id", cerberusJwtClaims.getId());
assertEquals("principal", cerberusJwtClaims.getPrincipal());
assertEquals("groups", cerberusJwtClaims.getGroups());
assertEquals(true, cerberusJwtClaims.getIsAdmin());
assertEquals("type", cerberusJwtClaims.getPrincipalType());
assertEquals(1, (long) cerberusJwtClaims.getRefreshCount());
assertEquals(OffsetDateTime.of(2000, 1, 1, 1, 1, 1, 1, ZoneOffset.UTC).toEpochSecond(), cerberusJwtClaims.getCreatedTs().toEpochSecond());
assertEquals(OffsetDateTime.of(3000, 1, 1, 1, 1, 1, 1, ZoneOffset.UTC).toEpochSecond(), cerberusJwtClaims.getExpiresTs().toEpochSecond());
}
Aggregations