Esempio 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());
 }
Esempio 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"));
 }
Esempio 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);
 }
Esempio 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());
 }
Esempio 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());
 }
Esempio 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());
 }
Esempio 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();
   }
 }
Esempio 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());
 }
Esempio n. 9
0
 @Test
 public void testClientAuthoritiesNotInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals(null, result.getAuthorities());
 }
Esempio n. 10
0
 @Test
 public void testExpiryResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertTrue(expiresIn + System.currentTimeMillis() / 1000 >= result.getExp());
 }
Esempio n. 11
0
 @Test
 public void testClientIdInAud() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertTrue(result.getAud().contains("client"));
 }
Esempio n. 12
0
 @Test
 public void testEmailInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("*****@*****.**", result.getEmail());
 }
Esempio n. 13
0
 @Test
 public void validateAuthTime() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertNotNull(result.getAuthTime());
 }
Esempio n. 14
0
 @Test
 public void testUserIdInResult() {
   Claims result = endpoint.checkToken(accessToken.getValue());
   assertEquals("olds", result.getUserName());
   assertEquals("12345", result.getUserId());
 }