You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.2 KiB
Kotlin
54 lines
2.2 KiB
Kotlin
2 years ago
|
package org.domaindrivenarchitecture.provs.server.infrastructure
|
||
2 years ago
|
|
||
2 years ago
|
import kotlinx.serialization.SerializationException
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.server.domain.CertmanagerEndpoint
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.server.domain.k3s.Certmanager
|
||
|
import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig
|
||
|
import org.domaindrivenarchitecture.provs.server.domain.k3s.Loopback
|
||
|
import org.domaindrivenarchitecture.provs.server.domain.k3s.Node
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.server.infrastructure.k3s.getK3sConfig
|
||
2 years ago
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||
|
import org.junit.jupiter.api.Test
|
||
|
import org.junit.jupiter.api.assertThrows
|
||
|
import java.io.FileNotFoundException
|
||
|
|
||
2 years ago
|
internal class K3sConfigRepositoryTest {
|
||
2 years ago
|
|
||
|
@Test
|
||
|
fun getConfig_successful() {
|
||
|
// when
|
||
2 years ago
|
val config = getK3sConfig(ConfigFileName("src/test/resources/k3sServerConfig.yaml"))
|
||
2 years ago
|
|
||
|
// then
|
||
2 years ago
|
assertEquals(
|
||
|
K3sConfig(
|
||
|
fqdn = "statistics.test.meissa-gmbh.de",
|
||
|
node = Node("162.55.164.138", "2a01:4f8:c010:672f::1"),
|
||
|
loopback = Loopback("192.168.5.1", "fc00::5:1"),
|
||
|
certmanager = Certmanager(
|
||
|
email = "admin@meissa-gmbh.de",
|
||
2 years ago
|
letsencryptEndpoint = CertmanagerEndpoint.prod
|
||
2 years ago
|
),
|
||
|
apple = true,
|
||
|
reprovision = true
|
||
|
), config
|
||
|
)
|
||
2 years ago
|
}
|
||
|
|
||
|
@Test
|
||
2 years ago
|
fun getConfig_fails_due_to_missing_property() {
|
||
|
val exception = assertThrows<SerializationException> {
|
||
2 years ago
|
getK3sConfig(ConfigFileName("src/test/resources/InvalidWorkplaceConfig.yaml"))
|
||
|
}
|
||
2 years ago
|
assertEquals("Fields [fqdn, node] are required for type with serial name 'org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig', but they were missing", exception.message)
|
||
2 years ago
|
}
|
||
|
|
||
|
@Test
|
||
2 years ago
|
fun getConfig_fails_due_to_missing_file() {
|
||
|
val exception = assertThrows<FileNotFoundException> {
|
||
2 years ago
|
getK3sConfig(ConfigFileName("src/test/resources/Idonotexist.yaml"))
|
||
|
}
|
||
2 years ago
|
assertEquals("src/test/resources/Idonotexist.yaml (No such file or directory)", exception.message)
|
||
2 years ago
|
}
|
||
|
}
|