use of com.auth0.client.HttpOptions in project auth0-java by auth0.
the class ManagementAPITest method shouldSetTimeoutsIfConfigured.
@Test
public void shouldSetTimeoutsIfConfigured() {
HttpOptions options = new HttpOptions();
options.setConnectTimeout(20);
options.setReadTimeout(30);
ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, options);
assertThat(api.getClient().connectTimeoutMillis(), is(20 * 1000));
assertThat(api.getClient().readTimeoutMillis(), is(30 * 1000));
}
use of com.auth0.client.HttpOptions in project auth0-java by auth0.
the class ManagementAPITest method shouldThrowOnTooManyMaxRetriesConfiguration.
@Test
public void shouldThrowOnTooManyMaxRetriesConfiguration() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Retries must be between zero and ten.");
HttpOptions options = new HttpOptions();
options.setManagementAPIMaxRetries(11);
}
use of com.auth0.client.HttpOptions in project auth0-java by auth0.
the class ManagementAPITest method shouldUseProxy.
@Test
public void shouldUseProxy() throws Exception {
Proxy proxy = Mockito.mock(Proxy.class);
ProxyOptions proxyOptions = new ProxyOptions(proxy);
HttpOptions httpOptions = new HttpOptions();
httpOptions.setProxyOptions(proxyOptions);
ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, httpOptions);
assertThat(api.getClient().proxy(), is(proxy));
Authenticator authenticator = api.getClient().proxyAuthenticator();
assertThat(authenticator, is(notNullValue()));
Route route = Mockito.mock(Route.class);
okhttp3.Request nonAuthenticatedRequest = new okhttp3.Request.Builder().url("https://test.com/app").addHeader("some-header", "some-value").build();
okhttp3.Response nonAuthenticatedResponse = new okhttp3.Response.Builder().protocol(Protocol.HTTP_2).code(200).message("OK").request(nonAuthenticatedRequest).build();
okhttp3.Request processedRequest = authenticator.authenticate(route, nonAuthenticatedResponse);
assertThat(processedRequest, is(nullValue()));
}
use of com.auth0.client.HttpOptions in project auth0-java by auth0.
the class ManagementAPITest method shouldThrowOnNegativeMaxRetriesConfiguration.
@Test
public void shouldThrowOnNegativeMaxRetriesConfiguration() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Retries must be between zero and ten.");
HttpOptions options = new HttpOptions();
options.setManagementAPIMaxRetries(-1);
}
use of com.auth0.client.HttpOptions in project auth0-java by auth0.
the class ManagementAPITest method proxyShouldNotProcessAlreadyAuthenticatedRequest.
@Test
public void proxyShouldNotProcessAlreadyAuthenticatedRequest() throws Exception {
Proxy proxy = Mockito.mock(Proxy.class);
ProxyOptions proxyOptions = new ProxyOptions(proxy);
proxyOptions.setBasicAuthentication("johndoe", "psswd".toCharArray());
assertThat(proxyOptions.getBasicAuthentication(), is("Basic am9obmRvZTpwc3N3ZA=="));
HttpOptions httpOptions = new HttpOptions();
httpOptions.setProxyOptions(proxyOptions);
ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN, httpOptions);
assertThat(api.getClient().proxy(), is(proxy));
Authenticator authenticator = api.getClient().proxyAuthenticator();
assertThat(authenticator, is(notNullValue()));
Route route = Mockito.mock(Route.class);
okhttp3.Request alreadyAuthenticatedRequest = new okhttp3.Request.Builder().url("https://test.com/app").addHeader("some-header", "some-value").header("Proxy-Authorization", "pre-existing-value").build();
okhttp3.Response alreadyAuthenticatedResponse = new okhttp3.Response.Builder().protocol(Protocol.HTTP_2).code(200).message("OK").request(alreadyAuthenticatedRequest).build();
okhttp3.Request processedRequest = authenticator.authenticate(route, alreadyAuthenticatedResponse);
assertThat(processedRequest, is(nullValue()));
}
Aggregations