|
|
|
|
@ -66,10 +66,14 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
vaultAddr, boundaryPolicyName := vault.Setup(t)
|
|
|
|
|
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault", "secrets", "enable", "-path="+c.VaultSecretPath, "kv-v2")
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs("secrets", "enable", "-path="+c.VaultSecretPath, "kv-v2"),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault", "secrets", "disable", c.VaultSecretPath)
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs("secrets", "disable", c.VaultSecretPath),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@ -79,14 +83,17 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
t.Log("Created Vault Credential")
|
|
|
|
|
|
|
|
|
|
// Create vault token for boundary
|
|
|
|
|
output = e2e.RunCommand(ctx, "vault", "token", "create",
|
|
|
|
|
"-no-default-policy=true",
|
|
|
|
|
"-policy="+boundaryPolicyName,
|
|
|
|
|
"-policy="+credentialPolicyName,
|
|
|
|
|
"-orphan=true",
|
|
|
|
|
"-period=20m",
|
|
|
|
|
"-renewable=true",
|
|
|
|
|
"-format=json",
|
|
|
|
|
output = e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"token", "create",
|
|
|
|
|
"-no-default-policy=true",
|
|
|
|
|
"-policy="+boundaryPolicyName,
|
|
|
|
|
"-policy="+credentialPolicyName,
|
|
|
|
|
"-orphan=true",
|
|
|
|
|
"-period=20m",
|
|
|
|
|
"-renewable=true",
|
|
|
|
|
"-format=json",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
var tokenCreateResult createTokenResponse
|
|
|
|
|
@ -96,11 +103,14 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
t.Log("Created Vault Cred Store Token")
|
|
|
|
|
|
|
|
|
|
// Create a credential store
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary", "credential-stores", "create", "vault",
|
|
|
|
|
"-scope-id", newProjectId,
|
|
|
|
|
"-vault-address", vaultAddr,
|
|
|
|
|
"-vault-token", credStoreToken,
|
|
|
|
|
"-format", "json",
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"credential-stores", "create", "vault",
|
|
|
|
|
"-scope-id", newProjectId,
|
|
|
|
|
"-vault-address", vaultAddr,
|
|
|
|
|
"-vault-token", credStoreToken,
|
|
|
|
|
"-format", "json",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
var newCredentialStoreResult credentialstores.CredentialStoreCreateResult
|
|
|
|
|
@ -110,12 +120,15 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
t.Logf("Created Credential Store: %s", newCredentialStoreId)
|
|
|
|
|
|
|
|
|
|
// Create a credential library
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary", "credential-libraries", "create", "vault",
|
|
|
|
|
"-credential-store-id", newCredentialStoreId,
|
|
|
|
|
"-vault-path", c.VaultSecretPath+"/data/"+secretName,
|
|
|
|
|
"-name", "e2e Automated Test Vault Credential Library",
|
|
|
|
|
"-credential-type", "ssh_private_key",
|
|
|
|
|
"-format", "json",
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"credential-libraries", "create", "vault",
|
|
|
|
|
"-credential-store-id", newCredentialStoreId,
|
|
|
|
|
"-vault-path", c.VaultSecretPath+"/data/"+secretName,
|
|
|
|
|
"-name", "e2e Automated Test Vault Credential Library",
|
|
|
|
|
"-credential-type", "ssh_private_key",
|
|
|
|
|
"-format", "json",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
var newCredentialLibraryResult credentiallibraries.CredentialLibraryCreateResult
|
|
|
|
|
@ -125,14 +138,19 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
t.Logf("Created Credential Library: %s", newCredentialLibraryId)
|
|
|
|
|
|
|
|
|
|
// Add brokered credentials to target
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary", "targets", "add-credential-sources",
|
|
|
|
|
"-id", newTargetId,
|
|
|
|
|
"-brokered-credential-source", newCredentialLibraryId,
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"targets", "add-credential-sources",
|
|
|
|
|
"-id", newTargetId,
|
|
|
|
|
"-brokered-credential-source", newCredentialLibraryId,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
|
|
|
|
|
// Get credentials for target
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary", "targets", "authorize-session", "-id", newTargetId, "-format", "json")
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary",
|
|
|
|
|
e2e.WithArgs("targets", "authorize-session", "-id", newTargetId, "-format", "json"),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
var newSessionAuthorizationResult targets.SessionAuthorizationResult
|
|
|
|
|
err = json.Unmarshal(output.Stdout, &newSessionAuthorizationResult)
|
|
|
|
|
@ -158,17 +176,20 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// Connect to target and print host's IP address using retrieved credentials
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary", "connect",
|
|
|
|
|
"-target-id", newTargetId,
|
|
|
|
|
"-exec", "/usr/bin/ssh", "--",
|
|
|
|
|
"-l", retrievedUser,
|
|
|
|
|
"-i", retrievedKeyPath,
|
|
|
|
|
"-o", "UserKnownHostsFile=/dev/null",
|
|
|
|
|
"-o", "StrictHostKeyChecking=no",
|
|
|
|
|
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
|
|
|
|
|
"-p", "{{boundary.port}}", // this is provided by boundary
|
|
|
|
|
"{{boundary.ip}}",
|
|
|
|
|
"hostname", "-i",
|
|
|
|
|
output = e2e.RunCommand(ctx, "boundary",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"connect",
|
|
|
|
|
"-target-id", newTargetId,
|
|
|
|
|
"-exec", "/usr/bin/ssh", "--",
|
|
|
|
|
"-l", retrievedUser,
|
|
|
|
|
"-i", retrievedKeyPath,
|
|
|
|
|
"-o", "UserKnownHostsFile=/dev/null",
|
|
|
|
|
"-o", "StrictHostKeyChecking=no",
|
|
|
|
|
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
|
|
|
|
|
"-p", "{{boundary.port}}", // this is provided by boundary
|
|
|
|
|
"{{boundary.ip}}",
|
|
|
|
|
"hostname", "-i",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
|
|
|
|
|
@ -202,10 +223,14 @@ func TestCreateVaultCredentialStoreApi(t *testing.T) {
|
|
|
|
|
// Configure vault
|
|
|
|
|
vaultAddr, boundaryPolicyName := vault.Setup(t)
|
|
|
|
|
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault", "secrets", "enable", "-path="+c.VaultSecretPath, "kv-v2")
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs("secrets", "enable", "-path="+c.VaultSecretPath, "kv-v2"),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault", "secrets", "disable", c.VaultSecretPath)
|
|
|
|
|
output := e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs("secrets", "disable", c.VaultSecretPath),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@ -215,14 +240,17 @@ func TestCreateVaultCredentialStoreApi(t *testing.T) {
|
|
|
|
|
t.Log("Created Vault Credential")
|
|
|
|
|
|
|
|
|
|
// Create vault token for boundary
|
|
|
|
|
output = e2e.RunCommand(ctx, "vault", "token", "create",
|
|
|
|
|
"-no-default-policy=true",
|
|
|
|
|
"-policy="+boundaryPolicyName,
|
|
|
|
|
"-policy="+credentialPolicyName,
|
|
|
|
|
"-orphan=true",
|
|
|
|
|
"-period=20m",
|
|
|
|
|
"-renewable=true",
|
|
|
|
|
"-format=json",
|
|
|
|
|
output = e2e.RunCommand(ctx, "vault",
|
|
|
|
|
e2e.WithArgs(
|
|
|
|
|
"token", "create",
|
|
|
|
|
"-no-default-policy=true",
|
|
|
|
|
"-policy="+boundaryPolicyName,
|
|
|
|
|
"-policy="+credentialPolicyName,
|
|
|
|
|
"-orphan=true",
|
|
|
|
|
"-period=20m",
|
|
|
|
|
"-renewable=true",
|
|
|
|
|
"-format=json",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
require.NoError(t, output.Err, string(output.Stderr))
|
|
|
|
|
var tokenCreateResult createTokenResponse
|
|
|
|
|
|