Skip to content

Commit d149069

Browse files
committed
Make the Android tests pass on <= 23
1 parent 6fcabb1 commit d149069

File tree

1 file changed

+16
-5
lines changed
  • android-test/src/androidTest/java/okhttp/android/test

1 file changed

+16
-5
lines changed

android-test/src/androidTest/java/okhttp/android/test/OkHttpTest.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ class OkHttpTest {
128128

129129
val clientCertificates = HandshakeCertificates.Builder()
130130
.addPlatformTrustedCertificates()
131-
.addInsecureHost(server.hostName)
131+
.apply {
132+
if (Build.VERSION.SDK_INT >= 24) {
133+
addInsecureHost(server.hostName)
134+
}
135+
}
132136
.build()
133137

134138
client = client.newBuilder()
@@ -141,7 +145,9 @@ class OkHttpTest {
141145
assertEquals(200, response.code)
142146
}
143147

144-
localhostInsecureRequest();
148+
if (Build.VERSION.SDK_INT >= 24) {
149+
localhostInsecureRequest();
150+
}
145151
}
146152

147153
@Test
@@ -278,8 +284,11 @@ class OkHttpTest {
278284
var socketClass: String? = null
279285

280286
val clientCertificates = HandshakeCertificates.Builder()
281-
.addPlatformTrustedCertificates()
282-
.addInsecureHost(server.hostName)
287+
.addPlatformTrustedCertificates().apply {
288+
if (Build.VERSION.SDK_INT >= 24) {
289+
addInsecureHost(server.hostName)
290+
}
291+
}
283292
.build()
284293

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

307-
localhostInsecureRequest();
316+
if (Build.VERSION.SDK_INT >= 24) {
317+
localhostInsecureRequest();
318+
}
308319
}
309320

310321
@Test

0 commit comments

Comments
 (0)