[skip ci] fix test_configureSsh
This commit is contained in:
parent
e35caca49a
commit
587e978d63
1 changed files with 14 additions and 6 deletions
|
@ -1,7 +1,9 @@
|
||||||
package org.domaindrivenarchitecture.provs.server.infrastructure
|
package org.domaindrivenarchitecture.provs.server.infrastructure
|
||||||
|
|
||||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.deleteFile
|
||||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
|
||||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
|
@ -12,15 +14,21 @@ class SshKtTest {
|
||||||
fun test_configureSsh() {
|
fun test_configureSsh() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val p = defaultTestContainer()
|
val prov = defaultTestContainer()
|
||||||
|
prov.task {
|
||||||
|
aptInstall("openssh-server")
|
||||||
|
deleteFile(pathSshdHardeningConfig, sudo = true)
|
||||||
|
}
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val res = p.configureSsh()
|
prov.configureSsh()
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(res.success)
|
|
||||||
assertTrue(p.fileContainsText("/etc/ssh/ssh_config","PasswordAuthentication no", sudo=true))
|
// Note: result of method configureSsh might have status failure as restart ssh within docker is not possible,
|
||||||
assertTrue(p.fileContainsText("/etc/ssh/sshd_config","PasswordAuthentication no", sudo=true))
|
// but files should have expected content
|
||||||
assertTrue(p.checkFile("/etc/ssh/sshd_config.d/sshd_hardening.conf"))
|
assertTrue(prov.fileContainsText("/etc/ssh/ssh_config","PasswordAuthentication no", sudo=true))
|
||||||
|
assertTrue(prov.fileContainsText("/etc/ssh/sshd_config","PasswordAuthentication no", sudo=true))
|
||||||
|
assertTrue(prov.checkFile("/etc/ssh/sshd_config.d/sshd_hardening.conf"))
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue