pl.allegro.tech.servicemesh.envoycontrol.assertions.HttpsEchoResponseAssertions.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.
The newest version!
package pl.allegro.tech.servicemesh.envoycontrol.assertions
import org.assertj.core.api.Assertions
import org.assertj.core.api.ObjectAssert
import pl.allegro.tech.servicemesh.envoycontrol.config.service.HttpsEchoContainer
import pl.allegro.tech.servicemesh.envoycontrol.config.service.HttpsEchoResponse
import java.util.function.Consumer
fun ObjectAssert.isOk(): ObjectAssert {
matches { it.response.isSuccessful }
return this
}
fun ObjectAssert.hasSNI(serverName: String): ObjectAssert = satisfies(Consumer {
val actualServerName = HttpsEchoResponse.objectMapper.readTree(it.body).at("/connection/servername").textValue()
Assertions.assertThat(actualServerName).isEqualTo(serverName)
})
fun ObjectAssert.isFrom(container: HttpsEchoContainer) = satisfies(Consumer {
Assertions.assertThat(container.containerName()).isEqualTo(it.hostname)
})