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