diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/ProvisionWorkplace.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/ProvisionWorkplace.kt index e4b4cf0..ff2c932 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/ProvisionWorkplace.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/ProvisionWorkplace.kt @@ -11,7 +11,7 @@ import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstallFromPpa import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptPurge import org.domaindrivenarchitecture.provs.ubuntu.keys.KeyPair import org.domaindrivenarchitecture.provs.ubuntu.keys.base.gpgFingerprint -import org.domaindrivenarchitecture.provs.ubuntu.keys.provisionKeysCurrentUser +import org.domaindrivenarchitecture.provs.ubuntu.keys.provisionKeys import org.domaindrivenarchitecture.provs.ubuntu.secret.secretSources.PromptSecretSource import org.domaindrivenarchitecture.provs.ubuntu.user.base.currentUserCanSudo import org.domaindrivenarchitecture.provs.ubuntu.user.base.makeUserSudoerWithNoSudoPasswordRequired @@ -49,7 +49,7 @@ fun Prov.provisionWorkplace( aptInstall("ssh gnupg curl git") - provisionKeysCurrentUser(gpg, ssh) + provisionKeys(gpg, ssh) provisionGit(gitUserName ?: whoami(), gitEmail, gpg?.let { gpgFingerprint(it.publicKey.plain()) }) installVirtualBoxGuestAdditions() diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeys.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeys.kt index 7b4bf0d..c9758c2 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeys.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeys.kt @@ -25,7 +25,7 @@ class KeyPairSource(val sourceType: SecretSourceType, val publicKey: String, val /** * provisions gpg and/or ssh keys for the current user */ -fun Prov.provisionKeysCurrentUser(gpgKeys: KeyPair? = null, sshKeys: KeyPair? = null) = requireAll { +fun Prov.provisionKeys(gpgKeys: KeyPair? = null, sshKeys: KeyPair? = null) = requireAll { gpgKeys?.let { configureGpgKeys(it, true) } sshKeys?.let { configureSshKeys(it) } ProvResult(true) // dummy diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/user/base/User.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/user/base/User.kt index f1cefe8..82d1477 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/user/base/User.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/ubuntu/user/base/User.kt @@ -9,7 +9,7 @@ import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.fileExists import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.userHome import org.domaindrivenarchitecture.provs.ubuntu.git.provisionGit import org.domaindrivenarchitecture.provs.ubuntu.keys.base.gpgFingerprint -import org.domaindrivenarchitecture.provs.ubuntu.keys.provisionKeysCurrentUser +import org.domaindrivenarchitecture.provs.ubuntu.keys.provisionKeys import org.domaindrivenarchitecture.provs.ubuntu.user.UserConfig import java.net.InetAddress @@ -55,7 +55,7 @@ fun Prov.createUser( * Does NOT CREATE the user. */ fun Prov.configureUser(config: UserConfig) = requireAll { - provisionKeysCurrentUser( + provisionKeys( config.gpg?.keyPair(), config.ssh?.keyPair() ) diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeysTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeysTest.kt index 9d10e38..e3372b9 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeysTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/ubuntu/keys/ProvisionKeysTest.kt @@ -3,18 +3,16 @@ package org.domaindrivenarchitecture.provs.ubuntu.keys import org.domaindrivenarchitecture.provs.core.Secret import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.junit.jupiter.api.Test -import org.junit.jupiter.api.condition.EnabledOnOs -import org.junit.jupiter.api.condition.OS internal class ProvisionKeysTest { @Test - fun provisionKeysCurrentUser() { + fun provisionKeys() { // given val a = defaultTestContainer() // when - val res = a.provisionKeysCurrentUser( + val res = a.provisionKeys( KeyPair(Secret(publicGPGSnakeoilKey()), Secret(privateGPGSnakeoilKey())), KeyPair(Secret(publicSSHSnakeoilKey()), Secret(privateSSHSnakeoilKey())) )