use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class AuthorizationCodeServicesBaseTests method testCreateAuthorizationCode.
@Test
public void testCreateAuthorizationCode() {
OAuth2Request storedOAuth2Request = RequestTokenFactory.createOAuth2Request("id", false);
OAuth2Authentication expectedAuthentication = new OAuth2Authentication(storedOAuth2Request, new TestAuthentication("test2", false));
String code = getAuthorizationCodeServices().createAuthorizationCode(expectedAuthentication);
assertNotNull(code);
OAuth2Authentication actualAuthentication = getAuthorizationCodeServices().consumeAuthorizationCode(code);
assertEquals(expectedAuthentication, actualAuthentication);
}
use of org.springframework.security.oauth2.provider.OAuth2Request 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.OAuth2Request in project spring-security-oauth by spring-projects.
the class DefaultAuthorizationRequestFactoryTests method testCreateAuthorizationThenOAuth2RequestWithGrantType.
@Test
public void testCreateAuthorizationThenOAuth2RequestWithGrantType() {
factory.setCheckUserScopes(true);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("client_id", "foo");
parameters.put("response_type", "token");
OAuth2Request request = factory.createAuthorizationRequest(parameters).createOAuth2Request();
assertEquals("implicit", request.getGrantType());
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class OAuth2RequestTests method testResourceIdsConstructorAssignment.
// gh-724
@Test
public void testResourceIdsConstructorAssignment() {
Set<String> resourceIds = new HashSet<String>(Arrays.asList("resourceId-1", "resourceId-2"));
OAuth2Request request = new OAuth2Request(Collections.<String, String>emptyMap(), "clientId", Collections.<GrantedAuthority>emptyList(), false, Collections.<String>emptySet(), resourceIds, "redirectUri", Collections.<String>emptySet(), Collections.<String, Serializable>emptyMap());
assertNotSame("resourceIds are the same", resourceIds, request.getResourceIds());
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class OAuth2RequestTests method testImplicitGrantType.
@Test
public void testImplicitGrantType() throws Exception {
parameters.put("response_type", "token");
OAuth2Request authorizationRequest = createFromParameters(parameters);
assertEquals("implicit", authorizationRequest.getGrantType());
}
Aggregations