use of com.auth0.client.auth.AuthAPI in project auth0-java by auth0.
the class AuthAPITest method shouldConfigureBodyLoggingFromOptions.
@Test
public void shouldConfigureBodyLoggingFromOptions() {
LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.BODY);
Set<String> headersToRedact = new HashSet<>();
headersToRedact.add("Authorization");
headersToRedact.add("Cookie");
loggingOptions.setHeadersToRedact(headersToRedact);
HttpOptions options = new HttpOptions();
options.setLoggingOptions(loggingOptions);
AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
assertThat(api.getClient().interceptors(), hasItem(isA(HttpLoggingInterceptor.class)));
for (Interceptor i : api.getClient().interceptors()) {
if (i instanceof HttpLoggingInterceptor) {
HttpLoggingInterceptor logging = (HttpLoggingInterceptor) i;
assertThat(logging.getLevel(), is(Level.BODY));
}
}
}
use of com.auth0.client.auth.AuthAPI in project auth0-java by auth0.
the class AuthAPITest method shouldUseConfiguredMaxRequests.
@Test
public void shouldUseConfiguredMaxRequests() {
HttpOptions options = new HttpOptions();
options.setMaxRequests(10);
AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
assertThat(api.getClient().dispatcher().getMaxRequests(), is(10));
}
use of com.auth0.client.auth.AuthAPI in project auth0-java by auth0.
the class AuthAPITest method shouldUseConfiguredTimeoutValues.
@Test
public void shouldUseConfiguredTimeoutValues() {
HttpOptions options = new HttpOptions();
options.setConnectTimeout(20);
options.setReadTimeout(30);
AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
assertThat(api.getClient().connectTimeoutMillis(), is(20 * 1000));
assertThat(api.getClient().readTimeoutMillis(), is(30 * 1000));
}
use of com.auth0.client.auth.AuthAPI in project app-auth0-idprovider by enonic.
the class Auth0CallbackService method retrieveUserInfo.
private UserInfo retrieveUserInfo(IdProviderKey idProviderKey, Tokens tokens) throws Auth0Exception {
final String appClientId = configurationService.getAppClientId(idProviderKey);
final String appSecret = configurationService.getAppSecret(idProviderKey);
final String appDomain = configurationService.getAppDomain(idProviderKey);
final UserInfo userInfo = new AuthAPI(appDomain, appClientId, appSecret).userInfo(tokens.getAccessToken()).execute();
return userInfo;
}
use of com.auth0.client.auth.AuthAPI in project auth0-java-mvc-common by auth0.
the class RequestProcessorTest method shouldSetMaxAgeIfProvided.
@Test
public void shouldSetMaxAgeIfProvided() {
AuthAPI client = new AuthAPI("me.auth0.com", "clientId", "clientSecret");
when(verifyOptions.getMaxAge()).thenReturn(906030);
RequestProcessor handler = new RequestProcessor.Builder(client, "code", verifyOptions).build();
HttpServletRequest request = new MockHttpServletRequest();
AuthorizeUrl builder = handler.buildAuthorizeUrl(request, response, "https://redirect.uri/here", "state", "nonce");
String authorizeUrl = builder.build();
assertThat(authorizeUrl, is(notNullValue()));
assertThat(authorizeUrl, containsString("max_age=906030"));
}
Aggregations