Search in sources :

Example 6 with LoggingOptions

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

the class AuthAPITest method shouldConfigureBasicLoggingFromOptions.

@Test
public void shouldConfigureBasicLoggingFromOptions() {
    LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.BASIC);
    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.BASIC));
        }
    }
}
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 7 with LoggingOptions

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

the class AuthAPITest method shouldConfigureNoneLoggingFromOptions.

@Test
public void shouldConfigureNoneLoggingFromOptions() {
    LoggingOptions loggingOptions = new LoggingOptions(LoggingOptions.LogLevel.NONE);
    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.NONE));
        }
    }
}
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 8 with LoggingOptions

use of com.auth0.client.LoggingOptions 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)

Aggregations

HttpOptions (com.auth0.client.HttpOptions)8 LoggingOptions (com.auth0.client.LoggingOptions)8 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)8 Test (org.junit.Test)8 RateLimitInterceptor (com.auth0.net.RateLimitInterceptor)4 TelemetryInterceptor (com.auth0.net.TelemetryInterceptor)4 HashSet (java.util.HashSet)2