From 7e1c25fc326b8a4a81d76fb85dac191d64761e32 Mon Sep 17 00:00:00 2001 From: bom Date: Wed, 13 Jul 2022 11:33:30 +0200 Subject: [PATCH] Add tests for ssh.kt --- .../provs/server/infrastructure/SshKtTest.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/SshKtTest.kt diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/SshKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/SshKtTest.kt new file mode 100644 index 0000000..4863ae6 --- /dev/null +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/SshKtTest.kt @@ -0,0 +1,26 @@ +package org.domaindrivenarchitecture.provs.server.infrastructure + +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText +import org.domaindrivenarchitecture.provs.test.defaultTestContainer +import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest +import org.junit.jupiter.api.Assertions.assertTrue + +class SshKtTest { + + @ExtensiveContainerTest + fun test_configureSsh() { + + // given + val p = defaultTestContainer() + + // when + val res = p.configureSsh() + + // then + assertTrue(res.success) + assertTrue(p.fileContainsText("/etc/ssh/ssh_config","PasswordAuthentication no", sudo=true)) + assertTrue(p.fileContainsText("/etc/ssh/sshd_config","PasswordAuthentication no", sudo=true)) + assertTrue(p.checkFile("/etc/ssh/sshd_config.d/sshd_hardening.conf")) + } +} \ No newline at end of file