use of org.springframework.security.oauth2.provider.AuthorizationRequest in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testCreateAuthorizationRequest.
@Test
public void testCreateAuthorizationRequest() {
AuthorizationRequest request = factory.createAuthorizationRequest(Collections.singletonMap("client_id", "foo"));
assertEquals("foo", request.getClientId());
}
use of org.springframework.security.oauth2.provider.AuthorizationRequest in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testCreateAuthorizationRequestWhenUserNotPermitted.
@Test
public void testCreateAuthorizationRequestWhenUserNotPermitted() {
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken("user", "N/A", AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_BAR")));
factory.setCheckUserScopes(true);
client.setScope(Collections.singleton("foo"));
AuthorizationRequest request = factory.createAuthorizationRequest(Collections.singletonMap("client_id", "foo"));
assertEquals("foo", request.getClientId());
assertEquals("[]", request.getScope().toString());
}
use of org.springframework.security.oauth2.provider.AuthorizationRequest in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testCreateAuthorizationRequestWithUserRoles.
@Test
public void testCreateAuthorizationRequestWithUserRoles() {
factory.setCheckUserScopes(true);
AuthorizationRequest request = factory.createAuthorizationRequest(Collections.singletonMap("client_id", "foo"));
assertEquals("foo", request.getClientId());
assertEquals("[bar]", request.getScope().toString());
}
use of org.springframework.security.oauth2.provider.AuthorizationRequest in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testSecretErased.
@Test
public void testSecretErased() {
factory.setCheckUserScopes(true);
Map<String, String> params = new HashMap<String, String>(Collections.singletonMap("client_id", "foo"));
params.put("client_secret", "shhh");
AuthorizationRequest auth = factory.createAuthorizationRequest(params);
OAuth2Request request = factory.createTokenRequest(auth, "client_credentials").createOAuth2Request(client);
assertNull(request.getRequestParameters().get("client_secret"));
}
use of org.springframework.security.oauth2.provider.AuthorizationRequest in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testCreateAuthorizationRequestWithDefaultScopes.
@Test
public void testCreateAuthorizationRequestWithDefaultScopes() {
AuthorizationRequest request = factory.createAuthorizationRequest(Collections.singletonMap("client_id", "foo"));
assertEquals("[bar]", request.getScope().toString());
}
Aggregations