* Fold EchAwareDns into AndroidDns
I don't think each DNS feature should be its own DNS class; instead the single
DNS implementation should be configurable.
None of these classes have shipped in a stable release, so there's no risk
of breaking backwards-compatibility.
* Track changes in EchClientTest
* Completely fake out the network for simple tests
This covers the happy path of OkHttp + MockWebServer with no
TLS.
There's nothing too exciting here, other than using Okio's
inMemorySocketPair instead of a proper TCP socket for data.
In a follow-up PR I intend to layer on TLS including all the
exotic options like ECH and handshake failures. I won't do
any actual cryptography, just like how this doesn't do any
actual TCP packets.
* Update okhttp-testing-support/src/main/kotlin/okhttp3/sockets/FakeNetwork.kt
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
* Spotless
* Track some API changes in Android tests
---------
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
* Add Android ECH support via DNS state machine
Adds AndroidDns, backed by the system resolver and Android's DnsResolver
for HTTPS/ECH records, driving okhttp's StateMachineDnsCall as a transport.
Adds Android17SocketAdapter for platform ALPN/session-ticket/ECH setup on
API 37+. Pins Robolectric android-test to SDK 36.
* Set up API 37 emulator matrix in CI
Refactor the android CI job to drive the emulator matrix off an explicit
target/arch include list and add an experimental, non-blocking API 37
(16 KB page-size) entry. Warm the Gradle cache by assembling the
instrumentation APK instead of running the Robolectric unit tests, match
the snapshot boot options on the run step so cached snapshots restore,
and bump emulator memory/GPU/feature flags for headless runs.
Extracted from the testing_ech branch so the emulator setup can land
ahead of the ECH work.
* Fix android-test instrumentation tests for the API 37 emulator
Three environmental differences surface on the API 37 emulator image and
make connectedCheck fail there:
- The GmsCore Conscrypt provider negotiates TLS 1.3 (not 1.2) from API 37
onward, so assert the version conditionally.
- The dual-stack loopback tries the unbound address first, emitting a
ConnectStart/ConnectFailed pair before the successful connect; filter
those pairs out so the event-sequence assertion is stable across single-
and dual-stack environments.
- Peer verification failures can arrive wrapped (as a cause or suppressed
exception) rather than thrown directly; accept any of those shapes.
These are independent of the Android 17 platform/ECH work, so they can
land with the emulator CI setup ahead of it.
* Move androidDeviceTest to androidTest
Rename the source directory for Android device tests to the standard `androidTest` location.
* skip tests for now on 21, 23
Enable AGP newDsl
- Rename to androidHostTest and include resources
- avoid running robolectric on JDK < 17
- Avoid connectedReleaseAndroidTest for now
The first half is EventListenerAdapter, which mechanically
converts event function calls and emits event objects.
The second half is EventRecorder, which validates that the
right events are published.
This is in preparation for a follow-up where I intend
to dynamically add EventListeners to a Call.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Make tests fail on UnsupportedOperationException
Will fail without the okio fix.
```
09:14:49.703 E FATAL EXCEPTION: MockWebServer TaskRunner (Ask Gemini)
Process: okhttp.android.test.test, PID: 10087
java.lang.UnsupportedOperationException
at javax.net.ssl.SSLSocket.shutdownOutput(SSLSocket.java:851)
at okio.internal.DefaultSocket$SocketSink.close(DefaultSocket.kt:95)
at okio.ForwardingSink.close(ForwardingSink.kt:37)
at mockwebserver3.internal.MockWebServerSocket$sink$1.close(MockWebServerSocket.kt:69)
at okio.RealBufferedSink.close(RealBufferedSink.kt:287)
at okhttp3.internal.http2.Http2Writer.close(Http2Writer.kt:331)
at okhttp3.internal.http2.Http2Connection.close$okhttp(Http2Connection.kt:474)
at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:638)
at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:619)
at okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(TaskQueue.kt:112)
at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:81)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
```
* cleanup
* Fix SSL Handshake issue affecting MockWebserver on Android 24
Only called in MWS, but fails on API 24 when called. Adds a single Junit 4 test to run on Android 21-24.
Add a test since Junit 5 wasn't running on older devices.
* fix version number
* reformat
* reformat
* Split android OkHttpClient tests.
current tests were using a single client then
testing real network (facebook, ...) and localhost insecure.
Split so we get clearer failures.
* New @StartStop extension for JUnit 5
This is a new take on our JUnit 5 extension. Rather than creating and managing
the MockWebServer instance in the extension, we let the user create it and all
the extension does is manage the lifecycle.
Note that this annotation doesn't require any external configuration - it doesn't
need a system-property to opt-into 'automatic' extensions, and it doesn't require
a class-level extension either.
* apiDump
* Switch to @StartStop for JUnit 5 tests
* Fixup visibility
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Use Assets and Resources based on platform.
Assets uncompressed on Android. Assuming that the AAR file will compress.
Use Resources, compressed on JVM.
* Merge okhttp-android into okhttp.
Since :okhttp is kmp, it isn't required to be separate. And also the okhttp-android/jvm artifact naming conflicts with it.
* Switch back to the kotlin JVM plugin
This does a ton of file moves from jvmMain to main, and jvmTest to test.
* Don't use AnimalSniffer on okcurl
* Use assertk more (#8150)