rename method provisionKeysCurrentUser

This commit is contained in:
az 2021-11-24 23:16:13 +01:00
parent e354e7f9be
commit cae96ca42f
4 changed files with 7 additions and 9 deletions

View file

@ -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()

View file

@ -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

View file

@ -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()
)

View file

@ -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()))
)