Exemplo n.º 1
0
 @Test
 public void testClientId() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("client", result.getAzp());
   assertEquals("client", result.getCid());
   assertEquals("client", result.getClientId());
 }
Exemplo n.º 2
0
 @Test
 public void testValidateAudParameter() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   List<String> aud = result.getAud();
   assertEquals(2, aud.size());
   assertTrue(aud.contains("scim"));
   assertTrue(aud.contains("client"));
 }
Exemplo n.º 3
0
 @Test
 public void validatateIssuedAtIsSmallerThanExpiredAt() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   Integer iat = result.getIat();
   assertNotNull(iat);
   Integer exp = result.getExp();
   assertNotNull(exp);
   assertTrue(iat < exp);
 }
Exemplo n.º 4
0
 @Test
 public void testIssuerInResults() throws Exception {
   tokenServices.setIssuer("http://some.other.issuer");
   tokenServices.afterPropertiesSet();
   accessToken = tokenServices.createAccessToken(authentication);
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertNotNull("iss field is not present", result.getIss());
   assertEquals("http://some.other.issuer/oauth/token", result.getIss());
 }
Exemplo n.º 5
0
 @Test
 public void testClientOnly() {
   authentication =
       new OAuth2Authentication(
           new AuthorizationRequest("client", Collections.singleton("scim.read"))
               .createOAuth2Request(),
           null);
   accessToken = tokenServices.createAccessToken(authentication);
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("client", result.getClientId());
   assertEquals("client", result.getUserId());
 }
Exemplo n.º 6
0
 @Test(expected = InvalidTokenException.class)
 public void testUpdatedApprovals() {
   Date thirtySecondsAhead = new Date(System.currentTimeMillis() + 30000);
   approvalStore.addApproval(
       new Approval()
           .setUserId(userId)
           .setClientId("client")
           .setScope("read")
           .setExpiresAt(thirtySecondsAhead)
           .setStatus(ApprovalStatus.APPROVED));
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals(null, result.getAuthorities());
 }
Exemplo n.º 7
0
 @Test
 public void testIssuerInResultsInNonDefaultZone() throws Exception {
   try {
     IdentityZone zone = MultitenancyFixture.identityZone("id", "subdomain");
     IdentityZoneHolder.set(zone);
     tokenServices.setIssuer("http://some.other.issuer");
     tokenServices.afterPropertiesSet();
     accessToken = tokenServices.createAccessToken(authentication);
     Claims result = endpoint.checkToken(accessToken.getValue());
     assertNotNull("iss field is not present", result.getIss());
     assertEquals("http://subdomain.some.other.issuer/oauth/token", result.getIss());
   } finally {
     IdentityZoneHolder.clear();
   }
 }
Exemplo n.º 8
0
 @Test(expected = InvalidTokenException.class)
 public void testExpiredApprovals() {
   approvalStore.revokeApproval(
       new Approval()
           .setUserId(userId)
           .setClientId("client")
           .setScope("read")
           .setExpiresAt(new Date())
           .setStatus(ApprovalStatus.APPROVED));
   approvalStore.addApproval(
       new Approval()
           .setUserId(userId)
           .setClientId("client")
           .setScope("read")
           .setExpiresAt(new Date())
           .setStatus(ApprovalStatus.APPROVED));
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals(null, result.getAuthorities());
 }
Exemplo n.º 9
0
 @Test
 public void testClientAuthoritiesNotInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals(null, result.getAuthorities());
 }
Exemplo n.º 10
0
 @Test
 public void testExpiryResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertTrue(expiresIn + System.currentTimeMillis() / 1000 >= result.getExp());
 }
Exemplo n.º 11
0
 @Test
 public void testClientIdInAud() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertTrue(result.getAud().contains("client"));
 }
Exemplo n.º 12
0
 @Test
 public void testEmailInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("*****@*****.**", result.getEmail());
 }
Exemplo n.º 13
0
 @Test
 public void validateAuthTime() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertNotNull(result.getAuthTime());
 }
Exemplo n.º 14
0
 @Test
 public void testUserIdInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("olds", result.getUserName());
   assertEquals("12345", result.getUserId());
 }