Skip to content

Commit

Permalink
mobile: Make Android HTTP proxy test hermetic (envoyproxy#35989)
Browse files Browse the repository at this point in the history
This updates the Android HTTP proxy test hermetic by sending a request
to a test proxy server instead of sending a request to `api.lyft.com`.

Risk Level: low (test only)
Testing: unit test
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Signed-off-by: Fredy Wijaya <[email protected]>
  • Loading branch information
fredyw authored Sep 5, 2024
1 parent 9a8fe85 commit 8788b9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions mobile/test/kotlin/integration/proxying/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ envoy_mobile_android_test(
srcs = [
"ProxyInfoIntentPerformHTTPRequestUsingProxyTest.kt",
],
exec_properties = {
"dockerNetwork": "standard",
},
native_deps = [
"//test/jni:libenvoy_jni_with_test_and_listener_extensions.so",
] + select({
Expand All @@ -28,6 +25,7 @@ envoy_mobile_android_test(
"//library/kotlin/io/envoyproxy/envoymobile:envoy_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing",
"//test/java/io/envoyproxy/envoymobile/engine/testing:http_proxy_test_server_factory_lib",
"//test/java/io/envoyproxy/envoymobile/engine/testing:http_test_server_factory_lib",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.envoyproxy.envoymobile.RequestHeadersBuilder
import io.envoyproxy.envoymobile.RequestMethod
import io.envoyproxy.envoymobile.engine.JniLibrary
import io.envoyproxy.envoymobile.engine.testing.HttpProxyTestServerFactory
import io.envoyproxy.envoymobile.engine.testing.HttpTestServerFactory
import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -41,16 +42,19 @@ class ProxyInfoIntentPerformHTTPRequestUsingProxyTest {
}

private lateinit var httpProxyTestServer: HttpProxyTestServerFactory.HttpProxyTestServer
private lateinit var httpTestServer: HttpTestServerFactory.HttpTestServer

@Before
fun setUp() {
httpProxyTestServer =
HttpProxyTestServerFactory.start(HttpProxyTestServerFactory.Type.HTTP_PROXY)
httpTestServer = HttpTestServerFactory.start(HttpTestServerFactory.Type.HTTP1_WITHOUT_TLS)
}

@After
fun tearDown() {
httpProxyTestServer.shutdown()
httpTestServer.shutdown()
}

@Test
Expand Down Expand Up @@ -86,8 +90,8 @@ class ProxyInfoIntentPerformHTTPRequestUsingProxyTest {
RequestHeadersBuilder(
method = RequestMethod.GET,
scheme = "http",
authority = "api.lyft.com",
path = "/ping"
authority = httpTestServer.address,
path = "/"
)
.build()

Expand All @@ -96,7 +100,7 @@ class ProxyInfoIntentPerformHTTPRequestUsingProxyTest {
.newStreamPrototype()
.setOnResponseHeaders { responseHeaders, _, _ ->
val status = responseHeaders.httpStatus ?: 0L
assertThat(status).isEqualTo(301)
assertThat(status).isEqualTo(200)
assertThat(responseHeaders.value("x-proxy-response")).isEqualTo(listOf("true"))
onResponseHeadersLatch.countDown()
}
Expand Down

0 comments on commit 8788b9b

Please sign in to comment.