Search in sources :

Example 31 with BaseClientDetails

use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.

the class JdbcClientDetailsServiceTests method testUpdateClientRedirectURI.

@Test
public void testUpdateClientRedirectURI() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("newClientIdWithNoDetails");
    service.addClientDetails(clientDetails);
    String[] redirectURI = { "http://localhost:8080", "http://localhost:9090" };
    clientDetails.setRegisteredRedirectUri(new HashSet<String>(Arrays.asList(redirectURI)));
    service.updateClientDetails(clientDetails);
    Map<String, Object> map = jdbcTemplate.queryForMap(SELECT_SQL, "newClientIdWithNoDetails");
    assertEquals("newClientIdWithNoDetails", map.get("client_id"));
    assertTrue(map.containsKey("web_server_redirect_uri"));
    assertEquals("http://localhost:8080,http://localhost:9090", map.get("web_server_redirect_uri"));
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Example 32 with BaseClientDetails

use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.

the class JdbcClientDetailsServiceTests method testInsertDuplicateClient.

@Test(expected = ClientAlreadyExistsException.class)
public void testInsertDuplicateClient() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("duplicateClientIdWithNoDetails");
    service.addClientDetails(clientDetails);
    service.addClientDetails(clientDetails);
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Example 33 with BaseClientDetails

use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.

the class JdbcClientDetailsServiceTests method testRemoveClient.

@Test
public void testRemoveClient() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("deletedClientIdWithNoDetails");
    service.addClientDetails(clientDetails);
    service.removeClientDetails(clientDetails.getClientId());
    int count = jdbcTemplate.queryForObject("select count(*) from oauth_client_details where client_id=?", Integer.class, "deletedClientIdWithNoDetails");
    assertEquals(0, count);
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Example 34 with BaseClientDetails

use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.

the class JdbcClientDetailsServiceTests method testAddClientWithNoDetails.

@Test
public void testAddClientWithNoDetails() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("addedClientIdWithNoDetails");
    service.addClientDetails(clientDetails);
    Map<String, Object> map = jdbcTemplate.queryForMap(SELECT_SQL, "addedClientIdWithNoDetails");
    assertEquals("addedClientIdWithNoDetails", map.get("client_id"));
    assertTrue(map.containsKey("client_secret"));
    assertEquals(null, map.get("client_secret"));
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Example 35 with BaseClientDetails

use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.

the class JdbcClientDetailsServiceTests method testUpdateNonExistentClient.

@Test(expected = NoSuchClientException.class)
public void testUpdateNonExistentClient() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("nosuchClientIdWithNoDetails");
    service.updateClientDetails(clientDetails);
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Aggregations

BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)42 Test (org.junit.Test)36 AuthorizationRequest (org.springframework.security.oauth2.provider.AuthorizationRequest)12 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)12 ClientDetails (org.springframework.security.oauth2.provider.ClientDetails)8 Authentication (org.springframework.security.core.Authentication)7 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)7 OAuth2Exception (org.springframework.security.oauth2.common.exceptions.OAuth2Exception)6 ClientDetailsService (org.springframework.security.oauth2.provider.ClientDetailsService)6 Before (org.junit.Before)5 Expression (org.springframework.expression.Expression)5 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)5 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 EvaluationContext (org.springframework.expression.EvaluationContext)4 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)4 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)4 MethodInvocation (org.aopalliance.intercept.MethodInvocation)3 TokenRequest (org.springframework.security.oauth2.provider.TokenRequest)3 SimpleMethodInvocation (org.springframework.security.util.SimpleMethodInvocation)3 Date (java.util.Date)2