pl.allegro.tech.servicemesh.envoycontrol.config.service.OAuthServerExtension.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 org.junit.jupiter.api.extension.ExtensionContext
import pl.allegro.tech.servicemesh.envoycontrol.config.sharing.ContainerPool
class OAuthServerExtension : ServiceExtension {
init {
beforeAll(null)
}
var started = false
private var container: OAuthServerContainer? = null
override fun container(): OAuthServerContainer = container!!
override fun beforeAll(context: ExtensionContext?) {
if (started) {
return
} else {
container = pool.acquire(this)
started = true
}
}
override fun afterAll(context: ExtensionContext?) {
pool.release(this)
}
fun getTokenAddress(provider: String = "auth") = "http://localhost:${container().port()}/$provider/token"
fun getJwksAddress(provider: String = "auth") = "http://${container().networkAlias()}:${container().oAuthPort()}/$provider/jwks"
companion object {
private val pool = ContainerPool { OAuthServerContainer() }
}
}