fix issuer url & tests

This commit is contained in:
jerger 2022-02-12 20:50:21 +01:00
parent 4928d94e95
commit 988339323f
6 changed files with 35 additions and 7 deletions

View file

@ -1,5 +1,12 @@
package org.domaindrivenarchitecture.provs.server.domain
enum class CertmanagerEndpoint {
staging, prod
staging, prod;
fun endpointUri(): String {
return if (this == staging)
"https://acme-staging-v02.api.letsencrypt.org/directory"
else
"https://acme-v02.api.letsencrypt.org/directory"
}
}

View file

@ -103,7 +103,8 @@ fun Prov.provisionK3sCertManager(certmanager: Certmanager) = task {
"le-issuer.template.yaml",
k3sResourcePath,
mapOf(
"endpoint" to certmanager.letsencryptEndpoint.name.lowercase(),
"endpoint" to certmanager.letsencryptEndpoint.endpointUri(),
"name" to certmanager.letsencryptEndpoint.name.lowercase(),
"email" to certmanager.email
),
"644",

View file

@ -1,13 +1,13 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: ${endpoint}
name: ${name}
spec:
acme:
email: ${email}
server: https://acme-${endpoint}-v02.api.letsencrypt.org/directory
server: ${endpoint}
privateKeySecretRef:
name: ${endpoint}
name: ${name}
solvers:
- http01:
ingress:

View file

@ -0,0 +1,20 @@
package org.domaindrivenarchitecture.provs.server.domain
import org.domaindrivenarchitecture.provs.server.domain.ServerType
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class CertmanagerEndpointTest {
@Test
fun shouldResultCorrectEndpoint() {
// given
val cut = CertmanagerEndpoint.prod
// when
val result = cut.endpointUri()
// then
assertEquals("https://acme-v02.api.letsencrypt.org/directory", result)
}
}

View file

@ -35,7 +35,7 @@ internal class NetworkKtTest {
loopback = Loopback("192.168.5.1", "fc00::5:1"),
certmanager = Certmanager(
email = "admin@meissa-gmbh.de",
letsencryptEndpoint = CertmanagerEndpoint.PROD
letsencryptEndpoint = CertmanagerEndpoint.prod
),
apple = true,
reprovision = true

View file

@ -27,7 +27,7 @@ internal class ConfigRepositoryTest {
loopback = Loopback("192.168.5.1", "fc00::5:1"),
certmanager = Certmanager(
email = "admin@meissa-gmbh.de",
letsencryptEndpoint = CertmanagerEndpoint.PROD
letsencryptEndpoint = CertmanagerEndpoint.prod
),
apple = true,
reprovision = true