pl.allegro.tech.servicemesh.envoycontrol.config.service.HttpsEchoContainer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-tests Show documentation
Show all versions of envoy-control-tests Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
package pl.allegro.tech.servicemesh.envoycontrol.config.service
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.convertValue
import okhttp3.Response
import org.testcontainers.containers.Network
import pl.allegro.tech.servicemesh.envoycontrol.config.containers.SSLGenericContainer
class HttpsEchoContainer : SSLGenericContainer("mendhak/http-https-echo@$hash"),
ServiceContainer {
companion object {
// We need to use hash because the image doesn't use tags and the tests will fail if there is an older version
// of the image pulled locally
const val hash = "sha256:cd9025b7cdb6b2e8dd6e4a403d50b2dea074835948411167fc86566cb4ae77b6"
const val PORT = 5678
}
override fun configure() {
super.configure()
withEnv("HTTP_PORT", "$PORT")
withNetwork(Network.SHARED)
}
override fun port() = PORT
}
class HttpsEchoResponse(val response: Response) {
companion object {
val objectMapper = ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
}
val body = response.use { it.body?.string() } ?: ""
val requestHeaders by lazy