diff --git a/integ-tests/src/commonTest/kotlin/dev/evo/elasticmagic/engine.kt b/integ-tests/src/commonTest/kotlin/dev/evo/elasticmagic/engine.kt index de73353159..0d6c87ab94 100644 --- a/integ-tests/src/commonTest/kotlin/dev/evo/elasticmagic/engine.kt +++ b/integ-tests/src/commonTest/kotlin/dev/evo/elasticmagic/engine.kt @@ -1,14 +1,5 @@ package dev.evo.elasticmagic -import dev.evo.elasticmagic.transport.Auth - import io.ktor.client.engine.HttpClientEngine -const val DEFAULT_ELASTIC_URL = "http://localhost:9200" -const val DEFAULT_ELASTIC_USER = "elastic" - -expect val elasticUrl: String - expect val httpEngine: HttpClientEngine - -expect val elasticAuth: Auth? diff --git a/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/engineJs.kt b/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/engineJs.kt index 00636bf50a..51586c817b 100644 --- a/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/engineJs.kt +++ b/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/engineJs.kt @@ -1,30 +1,6 @@ package dev.evo.elasticmagic -import dev.evo.elasticmagic.transport.Auth - import io.ktor.client.engine.HttpClientEngine import io.ktor.client.engine.js.Js -external val process: Process - -external interface Process { - val env: ProcessEnvVariables -} - -external object ProcessEnvVariables { - val ELASTIC_URL: String? - val ELASTIC_USER: String? - val ELASTIC_PASSWORD: String? -} - -actual val elasticUrl: String = process.env.ELASTIC_URL ?: DEFAULT_ELASTIC_URL - actual val httpEngine: HttpClientEngine = Js.create {} - -actual val elasticAuth: Auth? = when (val elasticPassword = process.env.ELASTIC_PASSWORD) { - null -> null - else -> Auth.Basic( - process.env.ELASTIC_USER ?: DEFAULT_ELASTIC_USER, - elasticPassword - ) -} diff --git a/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/envJs.kt b/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/envJs.kt new file mode 100644 index 0000000000..528da86664 --- /dev/null +++ b/integ-tests/src/jsTest/kotlin/dev/evo/elasticmagic/envJs.kt @@ -0,0 +1,3 @@ +package dev.evo.elasticmagic + +actual fun getenv(name: String): String? = js("process.env[name]") as String? diff --git a/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/engineJvm.kt b/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/engineJvm.kt index 1888a4f72d..9bba10fb80 100644 --- a/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/engineJvm.kt +++ b/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/engineJvm.kt @@ -1,15 +1,11 @@ package dev.evo.elasticmagic -import dev.evo.elasticmagic.transport.Auth - import io.ktor.client.engine.HttpClientEngine import io.ktor.client.engine.cio.CIO import java.security.cert.X509Certificate import javax.net.ssl.X509TrustManager -actual val elasticUrl: String = System.getenv("ELASTIC_URL") ?: DEFAULT_ELASTIC_URL - actual val httpEngine: HttpClientEngine = CIO.create { https { trustManager = object: X509TrustManager { @@ -25,11 +21,3 @@ actual val httpEngine: HttpClientEngine = CIO.create { } } } - -actual val elasticAuth: Auth? = when (val elasticPassword = System.getenv("ELASTIC_PASSWORD")) { - null -> null - else -> Auth.Basic( - System.getenv("ELASTIC_USER") ?: DEFAULT_ELASTIC_USER, - elasticPassword - ) -} diff --git a/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/envJvm.kt b/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/envJvm.kt new file mode 100644 index 0000000000..d7a8e1ce1d --- /dev/null +++ b/integ-tests/src/jvmTest/kotlin/dev/evo/elasticmagic/envJvm.kt @@ -0,0 +1,3 @@ +package dev.evo.elasticmagic + +actual fun getenv(name: String): String? = System.getenv(name) diff --git a/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/engineNative.kt b/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/engineNative.kt index 80f9e3396b..461beb6afe 100644 --- a/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/engineNative.kt +++ b/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/engineNative.kt @@ -1,24 +1,8 @@ package dev.evo.elasticmagic -import dev.evo.elasticmagic.transport.Auth - import io.ktor.client.engine.HttpClientEngine import io.ktor.client.engine.curl.Curl -import kotlinx.cinterop.toKString - -import platform.posix.getenv - -actual val elasticUrl: String = getenv("ELASTIC_URL")?.toKString() ?: DEFAULT_ELASTIC_URL - actual val httpEngine: HttpClientEngine = Curl.create { sslVerify = false } - -actual val elasticAuth: Auth? = when (val elasticPassword = getenv("ELASTIC_PASSWORD")?.toKString()) { - null -> null - else -> Auth.Basic( - getenv("ELASTIC_USER")?.toKString() ?: DEFAULT_ELASTIC_USER, - elasticPassword - ) -} diff --git a/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/envNative.kt b/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/envNative.kt new file mode 100644 index 0000000000..e3a4edf270 --- /dev/null +++ b/integ-tests/src/nativeTest/kotlin/dev/evo/elasticmagic/envNative.kt @@ -0,0 +1,5 @@ +package dev.evo.elasticmagic + +import kotlinx.cinterop.toKString + +actual fun getenv(name: String): String? = platform.posix.getenv(name)?.toKString()