use of okhttp3.mockwebserver.internal.tls.SslClient in project okhttp by square.
the class OkHttp method prepare.
@Override
public void prepare(Benchmark benchmark) {
super.prepare(benchmark);
client = new OkHttpClient.Builder().protocols(benchmark.protocols).build();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLSocketFactory socketFactory = sslClient.socketFactory;
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession session) {
return true;
}
};
client = new OkHttpClient.Builder().sslSocketFactory(socketFactory, sslClient.trustManager).hostnameVerifier(hostnameVerifier).build();
}
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project okhttp by square.
the class UrlConnection method prepare.
@Override
public void prepare(Benchmark benchmark) {
super.prepare(benchmark);
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLSocketFactory socketFactory = sslClient.socketFactory;
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
}
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project mapbox-events-android by mapbox.
the class TelemetryClientTest method checksRequestTimeoutFailure.
@Test
public void checksRequestTimeoutFailure() throws Exception {
Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
MapboxTelemetry.applicationContext = mockedContext;
OkHttpClient localOkHttpClientWithShortTimeout = new OkHttpClient.Builder().readTimeout(100, TimeUnit.MILLISECONDS).build();
HttpUrl localUrl = obtainBaseEndpointUrl();
SslClient sslClient = SslClient.localhost();
TelemetryClientSettings telemetryClientSettings = new TelemetryClientSettings.Builder().client(localOkHttpClientWithShortTimeout).baseUrl(localUrl).sslSocketFactory(sslClient.socketFactory).x509TrustManager(sslClient.trustManager).hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}).build();
TelemetryClient telemetryClient = new TelemetryClient("anyAccessToken", "anyUserAgent", telemetryClientSettings, mock(Logger.class));
List<Event> theEvent = obtainAnEvent();
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<String> bodyRef = new AtomicReference<>();
final AtomicBoolean failureRef = new AtomicBoolean();
Callback aCallback = provideACallback(latch, bodyRef, failureRef);
enqueueMockNoResponse(504);
telemetryClient.sendEvents(theEvent, aCallback);
latch.await();
assertTrue(failureRef.get());
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project keywhiz by square.
the class ClientUtilsTest method testSslOkHttpClientCreationWithCookies.
@Test
public void testSslOkHttpClientCreationWithCookies() throws Exception {
OkHttpClient sslClient = ClientUtils.sslOkHttpClient(config.getDevTrustStore(), cookieList);
assertThat(sslClient.followSslRedirects()).isFalse();
assertThat(sslClient.cookieJar()).isNotNull();
assertThat(sslClient.sslSocketFactory()).isNotNull();
java.util.List<HttpCookie> cookieList = ClientUtils.getCookieManager().getCookieStore().getCookies();
assertThat(cookieList).contains(sessionCookie);
}
Aggregations