use of gov.ca.cwds.config.logging.DebugRestTemplateInterceptor in project perry by ca-cwds.
the class NoStateUserInfoRestTemplateCustomizerTest method testCustomize.
@Test
public void testCustomize() throws Exception {
NoStateUserInfoRestTemplateCustomizer noStateUserInfoRestTemplateCustomizer = new NoStateUserInfoRestTemplateCustomizer();
OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(new AuthorizationCodeResourceDetails());
noStateUserInfoRestTemplateCustomizer.customize(oAuth2RestTemplate);
AccessTokenProviderChain accessTokenProvider = getFieldValue(oAuth2RestTemplate, "accessTokenProvider", AccessTokenProviderChain.class);
assert accessTokenProvider != null;
List list = getFieldValue(accessTokenProvider, "chain", List.class);
assert list.size() == 4;
assert list.stream().anyMatch(o -> o instanceof ImplicitAccessTokenProvider);
assert list.stream().anyMatch(o -> o instanceof ResourceOwnerPasswordAccessTokenProvider);
assert list.stream().anyMatch(o -> o instanceof ClientCredentialsAccessTokenProvider);
assert list.stream().anyMatch(o -> o instanceof NoStateAuthorizationCodeTokenProvider);
NoStateAuthorizationCodeTokenProvider noStateAuthorizationCodeTokenProvider = (NoStateAuthorizationCodeTokenProvider) list.stream().filter(o -> o instanceof NoStateAuthorizationCodeTokenProvider).findFirst().get();
assert !getFieldValue(noStateAuthorizationCodeTokenProvider, "stateMandatory", Boolean.class);
List interceptors = getFieldValue(noStateAuthorizationCodeTokenProvider, "interceptors", List.class);
assert interceptors.size() == 1;
assert interceptors.stream().anyMatch(o -> o instanceof DebugRestTemplateInterceptor);
}
use of gov.ca.cwds.config.logging.DebugRestTemplateInterceptor in project perry by ca-cwds.
the class NoStateUserInfoRestTemplateCustomizer method customize.
@Override
public void customize(OAuth2RestTemplate template) {
AuthorizationCodeAccessTokenProvider noStateAuthorizationCodeTokenProvider = new NoStateAuthorizationCodeTokenProvider();
noStateAuthorizationCodeTokenProvider.setInterceptors(Arrays.asList(new DebugRestTemplateInterceptor()));
noStateAuthorizationCodeTokenProvider.setStateMandatory(false);
template.setAccessTokenProvider(new AccessTokenProviderChain(Arrays.<AccessTokenProvider>asList(noStateAuthorizationCodeTokenProvider, new ImplicitAccessTokenProvider(), new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider())));
}
Aggregations