Search in sources :

Example 86 with ClientDetails

use of org.springframework.security.oauth2.provider.ClientDetails 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 87 with ClientDetails

use of org.springframework.security.oauth2.provider.ClientDetails 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 88 with ClientDetails

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

the class JdbcClientDetailsServiceTests method testLoadingClientIdWithAdditionalInformation.

@Test
public void testLoadingClientIdWithAdditionalInformation() {
    jdbcTemplate.update(INSERT_SQL, "clientIdWithAddInfo", null, null, null, null, null, null, null, null, null);
    jdbcTemplate.update("update oauth_client_details set additional_information=? where client_id=?", "{\"foo\":\"bar\"}", "clientIdWithAddInfo");
    ClientDetails clientDetails = service.loadClientByClientId("clientIdWithAddInfo");
    assertEquals("clientIdWithAddInfo", clientDetails.getClientId());
    assertEquals(Collections.singletonMap("foo", "bar"), clientDetails.getAdditionalInformation());
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) Test(org.junit.Test)

Example 89 with ClientDetails

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

the class JdbcClientDetailsServiceTests method testFindClients.

@Test
public void testFindClients() {
    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("aclient");
    service.addClientDetails(clientDetails);
    int count = service.listClientDetails().size();
    assertEquals(1, count);
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) Test(org.junit.Test)

Example 90 with ClientDetails

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

the class JdbcClientDetailsServiceTests method testLoadingClientIdWithNoDetails.

@Test
public void testLoadingClientIdWithNoDetails() {
    jdbcTemplate.update(INSERT_SQL, "clientIdWithNoDetails", null, null, null, null, null, null, null, null, null);
    ClientDetails clientDetails = service.loadClientByClientId("clientIdWithNoDetails");
    assertEquals("clientIdWithNoDetails", clientDetails.getClientId());
    assertFalse(clientDetails.isSecretRequired());
    assertNull(clientDetails.getClientSecret());
    assertFalse(clientDetails.isScoped());
    assertEquals(0, clientDetails.getScope().size());
    assertEquals(2, clientDetails.getAuthorizedGrantTypes().size());
    assertNull(clientDetails.getRegisteredRedirectUri());
    assertEquals(0, clientDetails.getAuthorities().size());
    assertEquals(null, clientDetails.getAccessTokenValiditySeconds());
    assertEquals(null, clientDetails.getAccessTokenValiditySeconds());
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) ClientDetails(org.springframework.security.oauth2.provider.ClientDetails) Test(org.junit.Test)

Aggregations

ClientDetails (org.springframework.security.oauth2.provider.ClientDetails)47 Test (org.junit.Test)39 BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)32 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)28 Authentication (org.springframework.security.core.Authentication)21 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)20 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)20 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)19 Date (java.util.Date)14 HashMap (java.util.HashMap)13 TokenRequest (org.springframework.security.oauth2.provider.TokenRequest)9 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)7 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)7 ClientDetailsService (org.springframework.security.oauth2.provider.ClientDetailsService)7 ClientRegistrationException (org.springframework.security.oauth2.provider.ClientRegistrationException)7 DBUnitTest (org.orcid.test.DBUnitTest)6 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)6 OAuth2Exception (org.springframework.security.oauth2.common.exceptions.OAuth2Exception)6 AuthorizationRequest (org.springframework.security.oauth2.provider.AuthorizationRequest)6 OrcidOauth2ClientAuthentication (org.orcid.core.oauth.OrcidOauth2ClientAuthentication)5