diff --git a/inngest-core/src/main/kotlin/com/inngest/Environment.kt b/inngest-core/src/main/kotlin/com/inngest/Environment.kt index e926d913..30976eab 100644 --- a/inngest-core/src/main/kotlin/com/inngest/Environment.kt +++ b/inngest-core/src/main/kotlin/com/inngest/Environment.kt @@ -16,24 +16,6 @@ object Environment { return System.getenv(InngestSystem.EventKey.value) ?: "" } - fun inngestSigningKey( - env: InngestEnv, - key: String? = null, - ): String { - if (key != null) return key - - return when (env) { - InngestEnv.Dev -> "test" - else -> { - val signingKey = System.getenv(InngestSystem.SigningKey.value) - if (signingKey == null) { - throw Exception("signing key is required") - } - signingKey - } - } - } - fun inngestEventApiBaseUrl( env: InngestEnv, url: String? = null, diff --git a/inngest-core/src/main/kotlin/com/inngest/ServeConfig.kt b/inngest-core/src/main/kotlin/com/inngest/ServeConfig.kt index ab65772e..573e0d1f 100644 --- a/inngest-core/src/main/kotlin/com/inngest/ServeConfig.kt +++ b/inngest-core/src/main/kotlin/com/inngest/ServeConfig.kt @@ -17,7 +17,17 @@ class ServeConfig( fun signingKey(): String { if (signingKey != null) return signingKey - return System.getenv(InngestSystem.EventKey.value) ?: "" + + return when (client.env) { + InngestEnv.Dev -> "test" + else -> { + val signingKey = System.getenv(InngestSystem.SigningKey.value) + if (signingKey == null) { + throw Exception("signing key is required") + } + signingKey + } + } } fun baseUrl(): String { diff --git a/inngest-core/src/test/kotlin/com/inngest/EnvironmentTest.kt b/inngest-core/src/test/kotlin/com/inngest/EnvironmentTest.kt index abda103c..75757e4b 100644 --- a/inngest-core/src/test/kotlin/com/inngest/EnvironmentTest.kt +++ b/inngest-core/src/test/kotlin/com/inngest/EnvironmentTest.kt @@ -19,29 +19,6 @@ internal class EnvironmentTest { // @Test // fun `test inngestEventKey with INNGEST_EVENT_KEY value`() {} - // Signing key - @Test - fun `test inngestSigningKey - dev`() { - assertEquals("test", Environment.inngestSigningKey(InngestEnv.Dev)) - } - - @Test - fun `test inngestSigningKey with key value`() { - val key = "signing key" - assertEquals(key, Environment.inngestSigningKey(InngestEnv.Dev, key)) - } - - @Test - fun `test inngestSigningKey - prod`() { - assertFails( - "signing key is required", - { Environment.inngestSigningKey(InngestEnv.Prod) }, - ) - } - - // @Test - // fun `test inngestSigningKey with INNGEST_SIGNING_KEY value - prod`() {} - // EventAPI URL @Test fun `test inngestEventApiBaseUrl - dev`() { diff --git a/inngest-core/src/test/kotlin/com/inngest/ServeConfigTest.kt b/inngest-core/src/test/kotlin/com/inngest/ServeConfigTest.kt index 7ef4430d..94864c35 100644 --- a/inngest-core/src/test/kotlin/com/inngest/ServeConfigTest.kt +++ b/inngest-core/src/test/kotlin/com/inngest/ServeConfigTest.kt @@ -3,17 +3,50 @@ package com.inngest import kotlin.test.* internal class ServeConfigTest { + val client = Inngest(appId = "test") + + // appId() @Test fun `should return client appId if none are passed in`() { - val client = Inngest(appId = "test") val config = ServeConfig(client) assertEquals(client.appId, config.appId()) } @Test fun `should return serve appId if passed in`() { - val client = Inngest(appId = "test") val config = ServeConfig(client = client, id = "hello") assertEquals("hello", config.appId()) } + + // signingKey() + @Test + fun `should return test string if not set - dev`() { + val config = ServeConfig(client = client) + assertEquals("test", config.signingKey()) + } + + @Test + fun `should throw error if not set - prod`() { + val prodClient = Inngest(appId = client.appId, env = "prod") + val config = ServeConfig(client = prodClient) + assertFails( + "signing key is required", + { config.signingKey() }, + ) + } + + // @Test + // fun `should return INNGEST_SIGNING_KEY value - prod`() {} + + @Test + fun `should return passed in value`() { + val key = "sigingkey" + val config = ServeConfig(client = client, signingKey = key) + assertEquals(key, config.signingKey()) + } + + // baseUrl() + // serveOrigin() + // servePath() + // logLevel() }