Search in sources :

Example 56 with Authenticator

use of okhttp3.Authenticator in project okhttp-digest by rburgst.

the class ProxyAuthenticationManualTest method testConnection_WithProxyBasicAuthWithTunnel_Expect200.

@Test
public void testConnection_WithProxyBasicAuthWithTunnel_Expect200() throws IOException {
    final BasicAuthenticator authenticator = givenBasicAuthenticator();
    final OkHttpClient client = givenHttpClientWithProxyAuth(authenticator);
    final Request request = new Request.Builder().url("https://www.google.com/favicon.ico").build();
    Response response = client.newCall(request).execute();
    assertEquals(200, response.code());
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) BasicAuthenticator(com.burgstaller.okhttp.basic.BasicAuthenticator) Request(okhttp3.Request) Test(org.junit.Test)

Example 57 with Authenticator

use of okhttp3.Authenticator in project okhttp-digest by rburgst.

the class ProxyAuthenticationManualTest method testConnection_WithProxyBasicAuthWithNotAllowedSites_Expect403.

@Test
public void testConnection_WithProxyBasicAuthWithNotAllowedSites_Expect403() throws IOException {
    final BasicAuthenticator authenticator = givenBasicAuthenticator();
    final OkHttpClient client = givenHttpClientWithProxyAuth(authenticator);
    final Request request = new Request.Builder().url("http://www.youtube.com").build();
    Response response = client.newCall(request).execute();
    assertEquals(403, response.code());
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) BasicAuthenticator(com.burgstaller.okhttp.basic.BasicAuthenticator) Request(okhttp3.Request) Test(org.junit.Test)

Example 58 with Authenticator

use of okhttp3.Authenticator in project okhttp-digest by rburgst.

the class ProxyAuthenticationManualTest method testConnection_WithProxyDigestAuthWithoutTunnel_Expect200.

@Test
public void testConnection_WithProxyDigestAuthWithoutTunnel_Expect200() throws IOException {
    final DigestAuthenticator authenticator = givenDigestAuthenticator();
    final OkHttpClient client = givenHttpClientWithProxyAuth(authenticator);
    final Request request = new Request.Builder().url("http://edition.cnn.com").build();
    Response response = client.newCall(request).execute();
    assertEquals(200, response.code());
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) DigestAuthenticator(com.burgstaller.okhttp.digest.DigestAuthenticator) Request(okhttp3.Request) Test(org.junit.Test)

Example 59 with Authenticator

use of okhttp3.Authenticator in project okhttp-digest by rburgst.

the class ProxyAuthenticationManualTest method testConnection_WithProxyBasicAuthWithoutTunnel_Expect200.

@Test
public void testConnection_WithProxyBasicAuthWithoutTunnel_Expect200() throws IOException {
    final BasicAuthenticator authenticator = givenBasicAuthenticator();
    final OkHttpClient client = givenHttpClientWithProxyAuth(authenticator);
    final Request request = new Request.Builder().url("http://edition.cnn.com").build();
    Response response = client.newCall(request).execute();
    assertEquals(200, response.code());
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) BasicAuthenticator(com.burgstaller.okhttp.basic.BasicAuthenticator) Request(okhttp3.Request) Test(org.junit.Test)

Example 60 with Authenticator

use of okhttp3.Authenticator in project okhttp-digest by rburgst.

the class ProxyAuthenticationManualTest method testConnection_WithProxyDigestAuthWithTunnel_Expect200.

@Test
public void testConnection_WithProxyDigestAuthWithTunnel_Expect200() throws IOException {
    final DigestAuthenticator authenticator = givenDigestAuthenticator();
    final OkHttpClient client = givenHttpClientWithProxyAuth(authenticator);
    final Request request = new Request.Builder().url("https://www.google.com/favicon.ico").build();
    Response response = client.newCall(request).execute();
    assertEquals(200, response.code());
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) DigestAuthenticator(com.burgstaller.okhttp.digest.DigestAuthenticator) Request(okhttp3.Request) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)37 Request (okhttp3.Request)27 OkHttpClient (okhttp3.OkHttpClient)26 Response (okhttp3.Response)24 MockResponse (okhttp3.mockwebserver.MockResponse)23 Authenticator (okhttp3.Authenticator)20 IOException (java.io.IOException)15 RecordingOkAuthenticator (okhttp3.internal.RecordingOkAuthenticator)15 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)13 Route (okhttp3.Route)12 BasicAuthenticator (com.burgstaller.okhttp.basic.BasicAuthenticator)9 DigestAuthenticator (com.burgstaller.okhttp.digest.DigestAuthenticator)8 CachingAuthenticator (com.burgstaller.okhttp.digest.CachingAuthenticator)7 InetSocketAddress (java.net.InetSocketAddress)7 RecordingAuthenticator (okhttp3.internal.RecordingAuthenticator)6 Credentials (com.burgstaller.okhttp.digest.Credentials)5 InetAddress (java.net.InetAddress)5 Proxy (java.net.Proxy)5 Interceptor (okhttp3.Interceptor)5 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)5