We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the issue
I want to test a client handling of Proxy Auth using mockserver as both the proxy and the origin server.
But I can't get Auth to fail.
What you are trying to do
package okhttp3.containers import assertk.assertThat import assertk.assertions.contains import java.net.HttpURLConnection import java.net.Proxy import java.net.URI import okhttp3.containers.BasicMockServerTest.Companion.MOCKSERVER_IMAGE import okio.buffer import okio.source import org.junit.jupiter.api.Test import org.mockserver.client.MockServerClient import org.mockserver.model.HttpRequest.request import org.mockserver.model.HttpResponse.response import org.mockserver.proxyconfiguration.ProxyConfiguration import org.testcontainers.containers.MockServerContainer import org.testcontainers.junit.jupiter.Container import org.testcontainers.junit.jupiter.Testcontainers @Testcontainers class ProxyWithAuthTest { @Container val mockServer: MockServerContainer = MockServerContainer(MOCKSERVER_IMAGE) .withNetworkAliases("mockserver") @Test fun testUrlConnectionPlaintextProxied() { MockServerClient(mockServer.host, mockServer.serverPort).use { mockServerClient -> mockServerClient.withProxyConfiguration( ProxyConfiguration.proxyConfiguration( ProxyConfiguration.Type.HTTP, mockServerClient.remoteAddress(), "admin", "password" ) ) val request = request().withPath("/person") .withQueryStringParameter("name", "peter") mockServerClient .`when`( request, ) .respond(response().withBody("Peter the person!")) val proxy = Proxy( Proxy.Type.HTTP, mockServerClient.remoteAddress(), ) val url = URI(mockServer.endpoint + "/person?name=peter").toURL() val connection = url.openConnection(proxy) as HttpURLConnection assertThat(connection.inputStream.source().buffer().readUtf8()).contains("Peter the person") } } }
MockServer version
5.15.0
MockServer Log
I can provide, but nothing interesting, and I suspect I'm using API wrong.
The text was updated successfully, but these errors were encountered:
I'm guessing with testcontainers this needs to be configured before starting
@Container val mockServer: MockServerContainer = MockServerContainer(MOCKSERVER_IMAGE) .withNetworkAliases("mockserver") .withCopyToContainer( MountableFile.forClasspathResource("/proxy-config.properties"), "/config/mockserver.properties" ) .withLogConsumer { println(it.utf8StringWithoutLineEnding) }
But I'm still working on the correct config.
Sorry, something went wrong.
No branches or pull requests
Describe the issue
I want to test a client handling of Proxy Auth using mockserver as both the proxy and the origin server.
But I can't get Auth to fail.
What you are trying to do
MockServer version
5.15.0
MockServer Log
I can provide, but nothing interesting, and I suspect I'm using API wrong.
The text was updated successfully, but these errors were encountered: