Search in sources :

Example 31 with HttpOptions

use of com.auth0.client.HttpOptions in project auth0-java by auth0.

the class AuthAPITest method shouldUseZeroIfNegativeTimoutConfigured.

@Test
public void shouldUseZeroIfNegativeTimoutConfigured() {
    HttpOptions options = new HttpOptions();
    options.setConnectTimeout(-1);
    options.setReadTimeout(-10);
    AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
    assertThat(api.getClient().connectTimeoutMillis(), is(0));
    assertThat(api.getClient().readTimeoutMillis(), is(0));
}
Also used : HttpOptions(com.auth0.client.HttpOptions) Test(org.junit.Test)

Example 32 with HttpOptions

use of com.auth0.client.HttpOptions in project auth0-java by auth0.

the class AuthAPITest method shouldConfigureHeaderLoggingFromOptions.

@Test
public void shouldConfigureHeaderLoggingFromOptions() {
    LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.HEADERS);
    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.HEADERS));
        }
    }
}
Also used : HttpOptions(com.auth0.client.HttpOptions) LoggingOptions(com.auth0.client.LoggingOptions) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Example 33 with HttpOptions

use of com.auth0.client.HttpOptions in project auth0-java-mvc-common by auth0.

the class AuthenticationControllerTest method shouldCreateAuthAPIClientWithoutCustomHttpOptions.

@Test
public void shouldCreateAuthAPIClientWithoutCustomHttpOptions() {
    ArgumentCaptor<HttpOptions> captor = ArgumentCaptor.forClass(HttpOptions.class);
    AuthenticationController.Builder spy = spy(AuthenticationController.newBuilder("domain", "clientId", "clientSecret"));
    spy.build();
    verify(spy).createAPIClient(eq("domain"), eq("clientId"), eq("clientSecret"), captor.capture());
    HttpOptions actual = captor.getValue();
    assertThat(actual, is(nullValue()));
}
Also used : HttpOptions(com.auth0.client.HttpOptions) Test(org.junit.jupiter.api.Test)

Aggregations

HttpOptions (com.auth0.client.HttpOptions)31 Test (org.junit.Test)29 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)9 LoggingOptions (com.auth0.client.LoggingOptions)8 ProxyOptions (com.auth0.client.ProxyOptions)8 RateLimitInterceptor (com.auth0.net.RateLimitInterceptor)6 Proxy (java.net.Proxy)6 okhttp3 (okhttp3)6 TelemetryInterceptor (com.auth0.net.TelemetryInterceptor)5 Request (com.auth0.net.Request)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 Test (org.junit.jupiter.api.Test)2 PasswordlessEmailResponse (com.auth0.json.auth.PasswordlessEmailResponse)1 PasswordlessSmsResponse (com.auth0.json.auth.PasswordlessSmsResponse)1