use of org.forgerock.oauth2.core.OAuth2Request in project OpenAM by OpenRock.
the class ClaimsParameterValidatorTest method shouldErrorValidatingJson.
@Test(expectedExceptions = BadRequestException.class)
public void shouldErrorValidatingJson() throws NotFoundException, BadRequestException, RedirectUriMismatchException, InvalidScopeException, InvalidRequestException, InvalidClientException, ServerException, UnsupportedResponseTypeException {
//given
OAuth2Request mockRequest = mock(OAuth2Request.class);
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
String responseTypes = "id_token";
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getClaimsParameterSupported()).willReturn(true);
given(mockRequest.getParameter(OAuth2Constants.Custom.CLAIMS)).willReturn(invalidClaimsString);
given(mockRequest.getParameter(OAuth2Constants.Params.RESPONSE_TYPE)).willReturn(responseTypes);
//when
claimsParameterValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.OAuth2Request in project OpenAM by OpenRock.
the class ClaimsParameterValidatorTest method shouldErrorValidatingResponseType.
@Test(expectedExceptions = BadRequestException.class)
public void shouldErrorValidatingResponseType() throws NotFoundException, BadRequestException, RedirectUriMismatchException, InvalidScopeException, InvalidRequestException, InvalidClientException, ServerException, UnsupportedResponseTypeException {
//given
OAuth2Request mockRequest = mock(OAuth2Request.class);
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
String responseTypes = "id_token";
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getClaimsParameterSupported()).willReturn(true);
given(mockRequest.getParameter(OAuth2Constants.Custom.CLAIMS)).willReturn(validClaimsString);
given(mockRequest.getParameter(OAuth2Constants.Params.RESPONSE_TYPE)).willReturn(responseTypes);
//when
claimsParameterValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.OAuth2Request in project OpenAM by OpenRock.
the class OpenIdConnectAuthorizeRequestValidatorTest method validateShouldFailForRequestWithNoOpenidScopeOnOidcClient.
@Test(expectedExceptions = InvalidRequestException.class)
public void validateShouldFailForRequestWithNoOpenidScopeOnOidcClient() throws Exception {
//Given
OAuth2Request request = mock(OAuth2Request.class);
given(clientRegistration.getAllowedScopes()).willReturn(Collections.singleton("openid"));
given(request.getParameter("client_id")).willReturn("CLIENT_ID");
given(request.getParameter("scope")).willReturn("nothing");
//When
requestValidator.validateRequest(request);
}
use of org.forgerock.oauth2.core.OAuth2Request in project OpenAM by OpenRock.
the class OpenIdConnectAuthorizeRequestValidatorTest method validateShouldFailWithInvalidRequestExceptionAndQueryParameters.
@Test
public void validateShouldFailWithInvalidRequestExceptionAndQueryParameters() throws Exception {
//Given
OAuth2Request request = mock(OAuth2Request.class);
given(clientRegistration.getAllowedScopes()).willReturn(Collections.singleton("openid"));
given(request.getParameter("client_id")).willReturn("CLIENT_ID");
given(request.getParameter("scope")).willReturn("nothing");
given(request.getParameter("response_type")).willReturn("code");
//When
try {
requestValidator.validateRequest(request);
fail();
} catch (InvalidRequestException e) {
//Then
assertEquals(e.getParameterLocation(), OAuth2Constants.UrlLocation.QUERY);
}
}
use of org.forgerock.oauth2.core.OAuth2Request in project OpenAM by OpenRock.
the class OpenIdConnectAuthorizeRequestValidatorTest method setUp.
@BeforeMethod
public void setUp() throws InvalidClientException, NotFoundException {
ClientRegistrationStore clientRegistrationStore = mock(ClientRegistrationStore.class);
clientRegistration = mock(ClientRegistration.class);
given(clientRegistrationStore.get(anyString(), Matchers.<OAuth2Request>anyObject())).willReturn(clientRegistration);
requestValidator = new OpenIdConnectAuthorizeRequestValidator(clientRegistrationStore);
}
Aggregations