Search in sources :

Example 21 with HttpOptions

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

the class ManagementAPITest method shouldUseZeroIfNegativeTimeoutConfigured.

@Test
public void shouldUseZeroIfNegativeTimeoutConfigured() {
    HttpOptions options = new HttpOptions();
    options.setConnectTimeout(-1);
    options.setReadTimeout(-1);
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, 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 22 with HttpOptions

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

the class ManagementAPITest method shouldUseConfiguredMaxRequestsPerHost.

@Test
public void shouldUseConfiguredMaxRequestsPerHost() {
    HttpOptions options = new HttpOptions();
    options.setMaxRequestsPerHost(10);
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, options);
    assertThat(api.getClient().dispatcher().getMaxRequestsPerHost(), is(10));
}
Also used : HttpOptions(com.auth0.client.HttpOptions) Test(org.junit.Test)

Example 23 with HttpOptions

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

the class ManagementAPITest method shouldConfigureBasicLoggingFromOptions.

@Test
public void shouldConfigureBasicLoggingFromOptions() {
    LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.BASIC);
    HttpOptions options = new HttpOptions();
    options.setLoggingOptions(loggingOptions);
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, 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.BASIC));
        }
    }
}
Also used : HttpOptions(com.auth0.client.HttpOptions) LoggingOptions(com.auth0.client.LoggingOptions) TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Example 24 with HttpOptions

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

the class ManagementAPITest method shouldUseCustomMaxRetriesIfConfigured.

@Test
public void shouldUseCustomMaxRetriesIfConfigured() {
    HttpOptions options = new HttpOptions();
    options.setManagementAPIMaxRetries(5);
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, options);
    assertThat(api.getClient().interceptors(), hasItem(isA(RateLimitInterceptor.class)));
    for (Interceptor i : api.getClient().interceptors()) {
        if (i instanceof RateLimitInterceptor) {
            RateLimitInterceptor rateLimitInterceptor = (RateLimitInterceptor) i;
            assertThat(rateLimitInterceptor.getMaxRetries(), is(5));
        }
    }
}
Also used : HttpOptions(com.auth0.client.HttpOptions) TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) Test(org.junit.Test)

Example 25 with HttpOptions

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

the class AuthAPITest method shouldUseConfiguredMaxRequestsPerHost.

@Test
public void shouldUseConfiguredMaxRequestsPerHost() {
    HttpOptions options = new HttpOptions();
    options.setMaxRequestsPerHost(10);
    AuthAPI api = new AuthAPI(DOMAIN, CLIENT_ID, CLIENT_SECRET, options);
    assertThat(api.getClient().dispatcher().getMaxRequestsPerHost(), is(10));
}
Also used : HttpOptions(com.auth0.client.HttpOptions) Test(org.junit.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