1
0
mirror of https://github.com/square/okhttp.git synced 2025-12-03 18:31:17 +03:00

Testing with JDK 12 and latest 11.0.3 (#5212)

JDK 12 and be more specific about when we expect failures, e.g. 11.0.3 has fixes we should take into account.
This commit is contained in:
Yuri Schimke
2019-07-02 07:21:58 +01:00
committed by GitHub
parent 81b0feeea9
commit bdd6c3944f
21 changed files with 235 additions and 55 deletions

View File

@@ -154,6 +154,21 @@ jobs:
- runtests:
platform: jdk9
testjdk12:
docker:
# best source of JDK 12 for now
- image: circleci/dynamodb:12.0.1-jdk
environment:
JVM_OPTS: -Xmx1g
TERM: dumb
steps:
- checkout
- runtests:
platform: jdk9
testconscrypt:
docker:
- image: circleci/openjdk:11.0.3-jdk-stretch
@@ -195,6 +210,10 @@ workflows:
branches:
ignore:
- gh-pages
- testjdk12:
filters:
branches:
only: master
- testconscrypt:
filters:
branches:
@@ -220,6 +239,9 @@ workflows:
- testjdk11:
requires:
- compile
- testjdk12:
requires:
- compile
- testconscrypt:
requires:
- compile

View File

@@ -25,7 +25,7 @@ import javax.net.ssl.HostnameVerifier;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.PlatformRule;
import okhttp3.testing.PlatformRule;
import okhttp3.Protocol;
import okhttp3.RecordingHostnameVerifier;
import okhttp3.Request;

View File

@@ -20,7 +20,7 @@ import java.net.UnknownHostException;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.PlatformRule;
import okhttp3.testing.PlatformRule;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

View File

@@ -13,18 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3
package okhttp3.testing
import okhttp3.internal.platform.ConscryptPlatform
import okhttp3.internal.platform.Jdk8WithJettyBootPlatform
import okhttp3.internal.platform.Jdk9Platform
import okhttp3.internal.platform.Platform
import org.conscrypt.Conscrypt
import org.hamcrest.BaseMatcher
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.CoreMatchers.not
import org.hamcrest.Description
import org.hamcrest.Matcher
import org.hamcrest.StringDescription
import org.hamcrest.TypeSafeMatcher
import org.junit.Assert
import org.junit.Assume.assumeThat
import org.junit.Assume.assumeTrue
import org.junit.rules.ExternalResource
import org.junit.AssumptionViolatedException
import org.junit.rules.TestRule
import org.junit.runners.model.Statement
import java.security.Security
/**
@@ -37,8 +46,34 @@ import java.security.Security
open class PlatformRule @JvmOverloads constructor(
val requiredPlatformName: String? = null,
val platform: Platform? = null
) : ExternalResource() {
override fun before() {
) : TestRule {
private val versionChecks = mutableListOf<Pair<Matcher<out Any>, Matcher<out Any>>>()
override fun apply(base: Statement, description: org.junit.runner.Description): Statement {
return object : Statement() {
@Throws(Throwable::class)
override fun evaluate() {
var failed = false
try {
setupPlatform()
base.evaluate()
} catch (e: AssumptionViolatedException) {
throw e
} catch (e: Throwable) {
failed = true
rethrowIfNotExpected(e)
} finally {
resetPlatform()
}
if (!failed) {
failIfExpected()
}
}
}
}
fun setupPlatform() {
if (requiredPlatformName != null) {
assumeThat(getPlatformSystemProperty(), equalTo(requiredPlatformName))
}
@@ -50,12 +85,72 @@ open class PlatformRule @JvmOverloads constructor(
}
}
override fun after() {
fun resetPlatform() {
if (platform != null) {
Platform.resetForTests()
}
}
fun expectFailureOnConscryptPlatform() {
expectFailure(platformMatches(CONSCRYPT_PROPERTY))
}
fun expectFailureFromJdkVersion(majorVersion: Int) {
expectFailure(fromMajor(majorVersion))
}
private fun expectFailure(
versionMatcher: Matcher<out Any>,
failureMatcher: Matcher<out Any> = CoreMatchers.anything()
) {
versionChecks.add(Pair(versionMatcher, failureMatcher))
}
fun platformMatches(platform: String): Matcher<Any> = object : BaseMatcher<Any>() {
override fun describeTo(description: Description) {
description.appendText(platform)
}
override fun matches(item: Any?): Boolean {
return getPlatformSystemProperty() == platform
}
}
fun fromMajor(version: Int): Matcher<PlatformVersion> {
return object : TypeSafeMatcher<PlatformVersion>() {
override fun describeTo(description: org.hamcrest.Description) {
description.appendText("JDK with version from $version")
}
override fun matchesSafely(item: PlatformVersion): Boolean {
return item.majorVersion >= version
}
}
}
fun rethrowIfNotExpected(e: Throwable) {
versionChecks.forEach { (versionMatcher, failureMatcher) ->
if (versionMatcher.matches(PlatformVersion) && failureMatcher.matches(e)) {
return
}
}
throw e
}
fun failIfExpected() {
versionChecks.forEach { (versionMatcher, failureMatcher) ->
if (versionMatcher.matches(PlatformVersion)) {
val description = StringDescription()
versionMatcher.describeTo(description)
description.appendText(" expected to fail with exception that ")
failureMatcher.describeTo(description)
Assert.fail(description.toString())
}
}
}
fun isConscrypt() = getPlatformSystemProperty() == CONSCRYPT_PROPERTY
fun isJdk9() = getPlatformSystemProperty() == JDK9_PROPERTY
@@ -148,7 +243,8 @@ open class PlatformRule @JvmOverloads constructor(
@JvmStatic
fun getPlatformSystemProperty(): String {
var property: String? = System.getProperty(PROPERTY_NAME)
var property: String? = System.getProperty(
PROPERTY_NAME)
if (property == null) {
property = when (Platform.get()) {
@@ -163,7 +259,8 @@ open class PlatformRule @JvmOverloads constructor(
}
@JvmStatic
fun conscrypt() = PlatformRule(CONSCRYPT_PROPERTY)
fun conscrypt() = PlatformRule(
CONSCRYPT_PROPERTY)
@JvmStatic
fun jdk9() = PlatformRule(JDK9_PROPERTY)
@@ -172,7 +269,8 @@ open class PlatformRule @JvmOverloads constructor(
fun jdk8() = PlatformRule(JDK8_PROPERTY)
@JvmStatic
fun jdk8alpn() = PlatformRule(JDK8_ALPN_PROPERTY)
fun jdk8alpn() = PlatformRule(
JDK8_ALPN_PROPERTY)
@JvmStatic
fun isAlpnBootEnabled(): Boolean = try {

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2019 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.testing
object PlatformVersion {
val majorVersion: Int by lazy {
when (val jvmSpecVersion = getJvmSpecVersion()) {
"1.8" -> 8
else -> jvmSpecVersion.toInt()
}
}
fun getJvmSpecVersion(): String {
return System.getProperty("java.specification.version", "unknown")
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3
package okhttp3.testing
import okhttp3.internal.platform.Platform
import org.junit.Rule
@@ -32,4 +32,19 @@ class PlatformRuleTest {
println(PlatformRule.getPlatformSystemProperty())
println(Platform.get().javaClass.simpleName)
}
@Test
fun testGreenCase() {
}
@Test
fun testGreenCaseFailingOnLater() {
platform.expectFailureFromJdkVersion(PlatformVersion.majorVersion + 1)
}
@Test
fun failureCase() {
platform.expectFailureFromJdkVersion(PlatformVersion.majorVersion)
check(false)
}
}

View File

@@ -17,6 +17,7 @@ package okhttp3
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.testing.PlatformRule
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Rule

View File

@@ -71,6 +71,7 @@ import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.QueueDispatcher;
import okhttp3.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okhttp3.tls.HeldCertificate;
import okio.Buffer;
@@ -92,10 +93,10 @@ import static java.util.Arrays.asList;
import static okhttp3.CipherSuite.TLS_DH_anon_WITH_AES_128_GCM_SHA256;
import static okhttp3.TestUtil.awaitGarbageCollection;
import static okhttp3.internal.Internal.addHeaderLenient;
import static okhttp3.internal.platform.PlatformTest.getJvmSpecVersion;
import static okhttp3.tls.internal.TlsUtil.localhost;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.Offset.offset;
import static org.hamcrest.CoreMatchers.anything;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
@@ -1316,7 +1317,6 @@ public final class CallTest {
// The _anon_ suites became unsupported in "1.8.0_201" and "11.0.2".
assumeFalse(System.getProperty("java.version", "unknown").matches("1\\.8\\.0_1\\d\\d"));
assumeFalse(System.getProperty("java.version", "unknown").matches("11"));
server.enqueue(new MockResponse());
@@ -1397,8 +1397,7 @@ public final class CallTest {
}
@Test public void matchingPinnedCertificate() throws Exception {
// TODO https://github.com/square/okhttp/issues/4703
assumeFalse(getJvmSpecVersion().equals("11"));
// Fails on 11.0.1 https://github.com/square/okhttp/issues/4703
enableTls();
server.enqueue(new MockResponse());

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.HostnameVerifier;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okhttp3.tls.HeldCertificate;
import org.junit.Before;

View File

@@ -22,6 +22,7 @@ import javax.net.ssl.SSLException;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import org.junit.Before;
import org.junit.Rule;

View File

@@ -21,6 +21,7 @@ import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.testing.PlatformRule;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -17,12 +17,14 @@ package okhttp3
import okhttp3.internal.platform.ConscryptPlatform
import okhttp3.internal.platform.Platform
import okhttp3.testing.PlatformRule
import org.assertj.core.api.Assertions.assertThat
import org.conscrypt.Conscrypt
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assume
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import java.net.InetAddress
@@ -56,6 +58,7 @@ class ConscryptTest {
}
@Test
@Ignore
fun testMozilla() {
assumeNetwork()
@@ -68,6 +71,7 @@ class ConscryptTest {
}
@Test
@Ignore
fun testGoogle() {
assumeNetwork()

View File

@@ -27,6 +27,7 @@ import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.mockwebserver.internal.duplex.MockDuplexResponseBody;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okio.BufferedSink;
import okio.BufferedSource;

View File

@@ -48,6 +48,7 @@ import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okio.Buffer;
import okio.BufferedSink;

View File

@@ -68,6 +68,7 @@ import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okio.Buffer;
import okio.BufferedSink;
@@ -99,8 +100,10 @@ import static okhttp3.mockwebserver.SocketPolicy.FAIL_HANDSHAKE;
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_INPUT_AT_END;
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_OUTPUT_AT_END;
import static okhttp3.mockwebserver.SocketPolicy.UPGRADE_TO_SSL_AT_END;
import static okhttp3.testing.PlatformRule.CONSCRYPT_PROPERTY;
import static okhttp3.tls.internal.TlsUtil.localhost;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.anything;
import static org.junit.Assert.fail;
/** Android's URLConnectionTest, ported to exercise OkHttp's Call API. */
@@ -685,6 +688,9 @@ public final class URLConnectionTest {
* http://code.google.com/p/android/issues/detail?id=13178
*/
@Test public void connectViaHttpsToUntrustedServer() throws Exception {
// https://github.com/square/okhttp/issues/5222
platform.expectFailureOnConscryptPlatform();
server.useHttps(handshakeCertificates.sslSocketFactory(), false);
server.enqueue(new MockResponse()); // unused

View File

@@ -44,7 +44,6 @@ import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClientTestRule;
import okhttp3.PlatformRule;
import okhttp3.Protocol;
import okhttp3.RecordingCookieJar;
import okhttp3.RecordingHostnameVerifier;
@@ -64,6 +63,7 @@ import okhttp3.mockwebserver.PushPromise;
import okhttp3.mockwebserver.QueueDispatcher;
import okhttp3.mockwebserver.RecordedRequest;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okio.Buffer;
import okio.BufferedSink;
@@ -75,7 +75,9 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -104,11 +106,12 @@ public final class HttpOverHttp2Test {
return asList(Protocol.H2_PRIOR_KNOWLEDGE, Protocol.HTTP_2);
}
@Rule public final PlatformRule platform = new PlatformRule();
private PlatformRule platform = new PlatformRule();
@Rule public final TestRule chain =
RuleChain.outerRule(platform).around(new Timeout(5, SECONDS));
@Rule public final TemporaryFolder tempDir = new TemporaryFolder();
@Rule public final MockWebServer server = new MockWebServer();
@Rule public final OkHttpClientTestRule clientTestRule = new OkHttpClientTestRule();
@Rule public final Timeout timeout = new Timeout(5, SECONDS);
private OkHttpClient client;
private Cache cache;
@@ -596,16 +599,16 @@ public final class HttpOverHttp2Test {
.build();
Call call1 = client1
.newCall(new Request.Builder()
.url(server.url("/"))
.build());
.url(server.url("/"))
.build());
OkHttpClient client2 = client.newBuilder()
.readTimeout(200, MILLISECONDS)
.build();
Call call2 = client2
.newCall(new Request.Builder()
.url(server.url("/"))
.build());
.url(server.url("/"))
.build());
Response response1 = call1.execute();
assertThat(response1.body().string()).isEqualTo("A");
@@ -900,26 +903,26 @@ public final class HttpOverHttp2Test {
QueueDispatcher dispatcher =
new RespondAfterCancelDispatcher(responseDequeuedLatches, requestCanceledLatches);
dispatcher.enqueueResponse(new MockResponse()
.setBodyDelay(10, TimeUnit.SECONDS)
.setBody("abc"));
.setBodyDelay(10, TimeUnit.SECONDS)
.setBody("abc"));
dispatcher.enqueueResponse(new MockResponse()
.setBodyDelay(10, TimeUnit.SECONDS)
.setBody("def"));
.setBodyDelay(10, TimeUnit.SECONDS)
.setBody("def"));
dispatcher.enqueueResponse(new MockResponse()
.setBody("ghi"));
.setBody("ghi"));
server.setDispatcher(dispatcher);
client = client.newBuilder()
.dns(new DoubleInetAddressDns())
.build();
.dns(new DoubleInetAddressDns())
.build();
callAndCancel(0, responseDequeuedLatches.get(0), requestCanceledLatches.get(0));
callAndCancel(1, responseDequeuedLatches.get(1), requestCanceledLatches.get(1));
// Make a third request to ensure the connection is reused.
Call call = client.newCall(new Request.Builder()
.url(server.url("/"))
.build());
.url(server.url("/"))
.build());
Response response = call.execute();
assertThat(response.body().string()).isEqualTo("ghi");
assertThat(server.takeRequest().getSequenceNumber()).isEqualTo(2);
@@ -1225,6 +1228,11 @@ public final class HttpOverHttp2Test {
}
@Test public void missingPongsFailsConnection() throws Exception {
if (protocol == Protocol.HTTP_2) {
// https://github.com/square/okhttp/issues/5221
platform.expectFailureFromJdkVersion(12);
}
// Ping every 500 ms, starting at 500 ms.
client = client.newBuilder()
.readTimeout(10, TimeUnit.SECONDS) // Confirm we fail before the read timeout.
@@ -1261,7 +1269,7 @@ public final class HttpOverHttp2Test {
}
private String firstFrame(List<String> logs, String type) {
for (String log: logs) {
for (String log : logs) {
if (log.contains(type)) {
return log;
}
@@ -1271,7 +1279,7 @@ public final class HttpOverHttp2Test {
private int countFrames(List<String> logs, String message) {
int result = 0;
for (String log: logs) {
for (String log : logs) {
if (log.equals(message)) {
result++;
}
@@ -1410,6 +1418,7 @@ public final class HttpOverHttp2Test {
@Override public void onResponse(Call call, Response response) throws IOException {
bodies.add(response.body().string());
}
@Override public void onFailure(Call call, IOException e) {
System.out.println(e);
}
@@ -1591,7 +1600,7 @@ public final class HttpOverHttp2Test {
if (callCount++ == 1) {
server.shutdown();
}
} catch(IOException e) {
} catch (IOException e) {
fail();
}
}

View File

@@ -15,7 +15,7 @@
*/
package okhttp3.internal.platform;
import okhttp3.PlatformRule;
import okhttp3.testing.PlatformRule;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -16,7 +16,7 @@
package okhttp3.internal.platform;
import java.lang.reflect.Method;
import okhttp3.PlatformRule;
import okhttp3.testing.PlatformRule;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -15,7 +15,7 @@
*/
package okhttp3.internal.platform;
import okhttp3.PlatformRule;
import okhttp3.testing.PlatformRule;
import org.junit.Rule;
import org.junit.Test;

View File

@@ -31,7 +31,6 @@ import okhttp3.Call;
import okhttp3.CertificatePinner;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClientTestRule;
import okhttp3.PlatformRule;
import okhttp3.RecordingHostnameVerifier;
import okhttp3.Request;
import okhttp3.Response;
@@ -39,17 +38,16 @@ import okhttp3.internal.platform.Platform;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.SocketPolicy;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okhttp3.tls.HeldCertificate;
import org.junit.Rule;
import org.junit.Test;
import static okhttp3.internal.platform.PlatformTest.getJvmSpecVersion;
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
public final class CertificatePinnerChainValidationTest {
@Rule public final PlatformRule platform = new PlatformRule();
@@ -59,8 +57,7 @@ public final class CertificatePinnerChainValidationTest {
/** The pinner should pull the root certificate from the trust manager. */
@Test public void pinRootNotPresentInChain() throws Exception {
// TODO https://github.com/square/okhttp/issues/4703
assumeFalse(getJvmSpecVersion().equals("11"));
// Fails on 11.0.1 https://github.com/square/okhttp/issues/4703
HeldCertificate rootCa = new HeldCertificate.Builder()
.serialNumber(1L)
@@ -119,8 +116,7 @@ public final class CertificatePinnerChainValidationTest {
/** The pinner should accept an intermediate from the server's chain. */
@Test public void pinIntermediatePresentInChain() throws Exception {
// TODO https://github.com/square/okhttp/issues/4703
assumeFalse(getJvmSpecVersion().equals("11"));
// Fails on 11.0.1 https://github.com/square/okhttp/issues/4703
HeldCertificate rootCa = new HeldCertificate.Builder()
.serialNumber(1L)
@@ -184,7 +180,7 @@ public final class CertificatePinnerChainValidationTest {
@Test public void unrelatedPinnedLeafCertificateInChain() throws Exception {
// https://github.com/square/okhttp/issues/4729
assumeFalse(getJvmSpecVersion().matches("1[123]"));
platform.expectFailureOnConscryptPlatform();
// Start with a trusted root CA certificate.
HeldCertificate rootCa = new HeldCertificate.Builder()
@@ -262,7 +258,7 @@ public final class CertificatePinnerChainValidationTest {
@Test public void unrelatedPinnedIntermediateCertificateInChain() throws Exception {
// https://github.com/square/okhttp/issues/4729
assumeFalse(getJvmSpecVersion().matches("1[123]"));
platform.expectFailureOnConscryptPlatform();
// Start with two root CA certificates, one is good and the other is compromised.
HeldCertificate rootCa = new HeldCertificate.Builder()
@@ -353,7 +349,7 @@ public final class CertificatePinnerChainValidationTest {
X509KeyManager x509KeyManager = newKeyManager(keystoreType, heldCertificate, intermediates);
X509TrustManager trustManager = newTrustManager(keystoreType, Collections.emptyList());
SSLContext sslContext = Platform.get().newSSLContext();
sslContext.init(new KeyManager[] { x509KeyManager }, new TrustManager[] { trustManager },
sslContext.init(new KeyManager[] {x509KeyManager}, new TrustManager[] {trustManager},
new SecureRandom());
return sslContext.getSocketFactory();
}

View File

@@ -32,11 +32,11 @@ import javax.security.auth.x500.X500Principal;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClientTestRule;
import okhttp3.PlatformRule;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.testing.PlatformRule;
import okhttp3.tls.HandshakeCertificates;
import okhttp3.tls.HeldCertificate;
import org.junit.Before;
@@ -44,13 +44,11 @@ import org.junit.Rule;
import org.junit.Test;
import static java.util.Arrays.asList;
import static okhttp3.PlatformRule.getPlatformSystemProperty;
import static okhttp3.internal.platform.PlatformTest.getJvmSpecVersion;
import static okhttp3.testing.PlatformRule.getPlatformSystemProperty;
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
public final class ClientAuthTest {
@Rule public final PlatformRule platform = new PlatformRule();
@@ -180,9 +178,8 @@ public final class ClientAuthTest {
}
@Test public void missingClientAuthFailsForNeeds() throws Exception {
// TODO https://github.com/square/okhttp/issues/4598
// Fails with 11.0.1 https://github.com/square/okhttp/issues/4598
// StreamReset stream was reset: PROT...
assumeFalse(getJvmSpecVersion().equals("11"));
OkHttpClient client = buildClient(null, clientIntermediateCa.certificate());
@@ -230,9 +227,8 @@ public final class ClientAuthTest {
}
@Test public void invalidClientAuthFails() throws Throwable {
// TODO https://github.com/square/okhttp/issues/4598
// Fails with https://github.com/square/okhttp/issues/4598
// StreamReset stream was reset: PROT...
assumeFalse(getJvmSpecVersion().matches("1[123]"));
HeldCertificate clientCert2 = new HeldCertificate.Builder()
.serialNumber(4L)