Skip to content

Commit

Permalink
Merge pull request #6071 from yschimke/android_tests_safe_on_23
Browse files Browse the repository at this point in the history
Make the Android tests pass on <= 23
  • Loading branch information
swankjesse committed May 19, 2020
2 parents 6fcabb1 + d149069 commit 9c173d2
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -128,7 +128,11 @@ class OkHttpTest {

val clientCertificates = HandshakeCertificates.Builder()
.addPlatformTrustedCertificates()
.addInsecureHost(server.hostName)
.apply {
if (Build.VERSION.SDK_INT >= 24) {
addInsecureHost(server.hostName)
}
}
.build()

client = client.newBuilder()
Expand All @@ -141,7 +145,9 @@ class OkHttpTest {
assertEquals(200, response.code)
}

localhostInsecureRequest();
if (Build.VERSION.SDK_INT >= 24) {
localhostInsecureRequest();
}
}

@Test
Expand Down Expand Up @@ -278,8 +284,11 @@ class OkHttpTest {
var socketClass: String? = null

val clientCertificates = HandshakeCertificates.Builder()
.addPlatformTrustedCertificates()
.addInsecureHost(server.hostName)
.addPlatformTrustedCertificates().apply {
if (Build.VERSION.SDK_INT >= 24) {
addInsecureHost(server.hostName)
}
}
.build()

client = client.newBuilder()
Expand All @@ -304,7 +313,9 @@ class OkHttpTest {
assertTrue(socketClass?.startsWith("com.android.org.conscrypt.") == true)
}

localhostInsecureRequest();
if (Build.VERSION.SDK_INT >= 24) {
localhostInsecureRequest();
}
}

@Test
Expand Down

0 comments on commit 9c173d2

Please sign in to comment.