Skip to content

Commit

Permalink
Make the Android tests pass on <= 23
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed May 19, 2020
1 parent 6fcabb1 commit d149069
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
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 d149069

Please sign in to comment.