use of org.forgerock.oauth2.core.OAuth2UrisFactory in project OpenAM by OpenRock.
the class DeviceCodeGrantTypeHandlerTest method setup.
@BeforeMethod
public void setup() throws Exception {
initMocks(this);
OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
when(providerSettingsFactory.get(request)).thenReturn(providerSettings);
when(providerSettings.getDeviceCodePollInterval()).thenReturn(5);
when(providerSettings.validateRequestedClaims(anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return (String) invocation.getArguments()[0];
}
});
OAuth2UrisFactory oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
when(oAuth2UrisFactory.get(request)).thenReturn(oAuth2Uris);
ClientAuthenticator clientAuthenticator = mock(ClientAuthenticator.class);
ClientRegistration clientRegistration = mock(ClientRegistration.class);
when(clientAuthenticator.authenticate(eq(request), anyString())).thenReturn(clientRegistration);
accessTokenGenerator = new GrantTypeAccessTokenGenerator(tokenStore);
when(tokenStore.createAccessToken(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anySetOf(String.class), any(RefreshToken.class), anyString(), anyString(), any(OAuth2Request.class))).thenReturn(accessToken);
when(tokenStore.createRefreshToken(anyString(), anyString(), anyString(), anyString(), anySetOf(String.class), any(OAuth2Request.class), anyString())).thenReturn(refreshToken);
ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
InvalidClientException expectedResult = mock(InvalidClientException.class);
when(expectedResult.getError()).thenReturn("invalid_client");
when(failureFactory.getException()).thenReturn(expectedResult);
when(failureFactory.getException(anyString())).thenReturn(expectedResult);
when(failureFactory.getException(any(OAuth2Request.class), anyString())).thenReturn(expectedResult);
grantTypeHandler = new DeviceCodeGrantTypeHandler(providerSettingsFactory, clientAuthenticator, tokenStore, clientRegistrationStore, failureFactory, oAuth2UrisFactory, accessTokenGenerator);
}
use of org.forgerock.oauth2.core.OAuth2UrisFactory in project OpenAM by OpenRock.
the class OpenAMResourceSetStoreTest method setup.
@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() throws Exception {
dataStore = mock(TokenDataStore.class);
OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
OAuth2UrisFactory<RealmInfo> oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
OAuth2Uris oAuth2Uris = mock(OAuth2Uris.class);
TokenIdGenerator idGenerator = mock(TokenIdGenerator.class);
store = new OpenAMResourceSetStore("REALM", providerSettingsFactory, oAuth2UrisFactory, idGenerator, dataStore);
given(oAuth2UrisFactory.get(Matchers.<OAuth2Request>anyObject())).willReturn(oAuth2Uris);
given(oAuth2Uris.getResourceSetRegistrationPolicyEndpoint(anyString())).willReturn("POLICY_URI");
}
Aggregations