Search in sources :

Example 1 with LoggingOptions

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

the class ManagementAPITest 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);
    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.BODY));
        }
    }
}
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) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with LoggingOptions

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

the class ManagementAPITest method shouldConfigureNoneLoggingFromOptions.

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

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

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

the class ManagementAPITest 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);
    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.HEADERS));
        }
    }
}
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) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with LoggingOptions

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

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