add recognition of ssh key type to determine ssh file names
parent
552c6e9445
commit
a4bb1d228c
@ -1,25 +1,48 @@
|
||||
package org.domaindrivenarchitecture.provs.framework.ubuntu.keys.base
|
||||
|
||||
import org.domaindrivenarchitecture.provs.framework.core.Secret
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.keys.KeyPair
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.keys.privateSSHSnakeoilKey
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.keys.publicSSHSnakeoilKey
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContent
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.keys.*
|
||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
|
||||
internal class SshKtTest {
|
||||
|
||||
@ContainerTest
|
||||
fun configureSshKeys() {
|
||||
fun configureSshKeys_for_ssh_type_rsa() {
|
||||
// given
|
||||
val a = defaultTestContainer()
|
||||
val prov = defaultTestContainer()
|
||||
|
||||
// when
|
||||
val res = a.configureSshKeys(KeyPair(Secret(publicSSHSnakeoilKey()), Secret(privateSSHSnakeoilKey())))
|
||||
val res = prov.configureSshKeys(SshKeyPair(Secret(publicSSHRSASnakeoilKey()), Secret(privateSSHRSASnakeoilKey())))
|
||||
|
||||
// then
|
||||
assertTrue(res.success)
|
||||
|
||||
val publicSshKeyFileContent = prov.fileContent("~/.ssh/id_rsa.pub")
|
||||
assertEquals(publicSSHRSASnakeoilKey() + "\n", publicSshKeyFileContent)
|
||||
|
||||
val privateSshKeyFileContent = prov.fileContent("~/.ssh/id_rsa")
|
||||
assertEquals(privateSSHRSASnakeoilKey() + "\n", privateSshKeyFileContent)
|
||||
}
|
||||
|
||||
@ContainerTest
|
||||
fun configureSshKeys_for_ssh_type_ed25519() {
|
||||
// given
|
||||
val prov = defaultTestContainer()
|
||||
|
||||
// when
|
||||
val res = prov.configureSshKeys(SshKeyPair(Secret(publicED25519SnakeOilKey()), Secret(privateED25519SnakeOilKey())))
|
||||
|
||||
// then
|
||||
assertTrue(res.success)
|
||||
|
||||
val publicSshKeyFileContent = prov.fileContent("~/.ssh/id_ed25519.pub")
|
||||
assertEquals(publicED25519SnakeOilKey() + "\n", publicSshKeyFileContent)
|
||||
|
||||
val privateSshKeyFileContent = prov.fileContent("~/.ssh/id_ed25519")
|
||||
assertEquals(privateED25519SnakeOilKey() + "\n", privateSshKeyFileContent)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue