diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt index f229ac9..3cacf98 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/cli/CliUtils.kt @@ -85,12 +85,6 @@ private fun createRemoteProvInstance( } -internal fun retrievePassword(cliCommand: TargetCliCommand): Secret? { - var password: Secret? = null - if (cliCommand.isValidRemote() && cliCommand.passwordInteractive) { - password = - PromptSecretSource("Password for user $cliCommand.userName!! on $cliCommand.remoteHost!!").secret() - - } - return password -} +internal fun getPasswordToConfigureSudoWithoutPassword(): Secret { + return PromptSecretSource("password to configure sudo without password.").secret() +} \ No newline at end of file diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/domain/CliTargetCommandTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/domain/CliTargetCommandTest.kt index c69409b..bacb2b3 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/domain/CliTargetCommandTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/domain/CliTargetCommandTest.kt @@ -4,7 +4,7 @@ import io.mockk.* import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.Secret import org.domaindrivenarchitecture.provs.framework.core.cli.createProvInstance -import org.domaindrivenarchitecture.provs.framework.core.cli.retrievePassword +import org.domaindrivenarchitecture.provs.framework.core.cli.getPasswordToConfigureSudoWithoutPassword import org.domaindrivenarchitecture.provs.framework.core.local import org.domaindrivenarchitecture.provs.framework.core.processors.PrintOnlyProcessor import org.domaindrivenarchitecture.provs.framework.core.remote @@ -23,8 +23,8 @@ internal class CliTargetCommandKtTest { mockkStatic(::remote) every { remote(any(), any(), any(), any()) } returns Prov.newInstance(PrintOnlyProcessor()) - mockkStatic(::retrievePassword) - every { retrievePassword(any()) } returns Secret("sec") + mockkStatic(::getPasswordToConfigureSudoWithoutPassword) + every { getPasswordToConfigureSudoWithoutPassword() } returns Secret("sec") } @AfterAll @@ -33,7 +33,7 @@ internal class CliTargetCommandKtTest { unmockkObject(Prov) unmockkStatic(::local) unmockkStatic(::remote) - unmockkStatic(::retrievePassword) + unmockkStatic(::getPasswordToConfigureSudoWithoutPassword) } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt index 25aadb7..0e260c8 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt @@ -7,7 +7,7 @@ import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand import org.domaindrivenarchitecture.provs.desktop.domain.* import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig import org.domaindrivenarchitecture.provs.framework.core.* -import org.domaindrivenarchitecture.provs.framework.core.cli.retrievePassword +import org.domaindrivenarchitecture.provs.framework.core.cli.getPasswordToConfigureSudoWithoutPassword import org.domaindrivenarchitecture.provs.framework.core.processors.DummyProcessor import org.domaindrivenarchitecture.provs.test.setRootLoggingLevel import org.junit.jupiter.api.AfterAll @@ -52,8 +52,8 @@ internal class ApplicationKtTest { cmd = "mocked command" ) - mockkStatic(::retrievePassword) - every { retrievePassword(any()) } returns Secret("sec") + mockkStatic(::getPasswordToConfigureSudoWithoutPassword) + every { getPasswordToConfigureSudoWithoutPassword() } returns Secret("sec") } @Suppress("unused") // false positive @@ -65,7 +65,7 @@ internal class ApplicationKtTest { unmockkStatic(::remote) unmockkStatic(::getConfig) unmockkStatic(Prov::provisionDesktop) - unmockkStatic(::retrievePassword) + unmockkStatic(::getPasswordToConfigureSudoWithoutPassword) } }