use of org.forgerock.oauth2.core.exceptions.InvalidClientException in project OpenAM by OpenRock.
the class ClaimsParameterValidatorTest method shouldValidateClaimsParameter.
@Test
public void shouldValidateClaimsParameter() throws NotFoundException, BadRequestException, RedirectUriMismatchException, InvalidScopeException, InvalidRequestException, InvalidClientException, ServerException, UnsupportedResponseTypeException {
//given
OAuth2Request mockRequest = mock(OAuth2Request.class);
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
String responseTypes = "code token 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.exceptions.InvalidClientException in project OpenAM by OpenRock.
the class SubjectTypeValidatorTest method shouldValidateRequest.
@Test
public void shouldValidateRequest() throws InvalidClientException, NotFoundException, ServerException {
//given
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
OAuth2Request mockRequest = mock(OAuth2Request.class);
OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class);
Set<String> subjectTypesSupported = new HashSet<String>();
subjectTypesSupported.add("public");
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported);
given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID");
given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration);
given(mockClientRegistration.getSubjectType()).willReturn("public");
//when
subjectTypeValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.exceptions.InvalidClientException in project OpenAM by OpenRock.
the class SubjectTypeValidatorTest method shouldFailSubjectTypeNotSupported.
@Test(expectedExceptions = InvalidClientException.class)
public void shouldFailSubjectTypeNotSupported() throws InvalidClientException, NotFoundException, ServerException {
//given
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
OAuth2Request mockRequest = mock(OAuth2Request.class);
OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class);
Set<String> subjectTypesSupported = new HashSet<String>();
subjectTypesSupported.add("public");
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported);
given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID");
given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration);
given(mockClientRegistration.getSubjectType()).willReturn("pairwise");
//when
subjectTypeValidator.validateRequest(mockRequest);
//then
}
Aggregations