refact(e2e): Add WithEnv option to RunCommand
This was done to keep the scope of environment variables to just the command execution
This commit is contained in:
1 parent
1cc2b0b820
commit
a956e8dec9
17 files changed
+487
-266
No files matched your search
@@ -36,11 +36,14 @@ func TestConnectTargetWithSshCli(t *testing.T) {
|
||||
|
||||
// Create credentials
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary", "credentials", "create", "ssh-private-key",
|
||||
"-credential-store-id", newCredentialStoreId,
|
||||
"-username", c.TargetSshUser,
|
||||
"-private-key", "file://"+c.TargetSshKeyPath,
|
||||
"-format", "json",
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"credentials", "create", "ssh-private-key",
|
||||
"-credential-store-id", newCredentialStoreId,
|
||||
"-username", c.TargetSshUser,
|
||||
"-private-key", "file://"+c.TargetSshKeyPath,
|
||||
"-format", "json",
|
||||
),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
var newCredentialsResult credentials.CredentialCreateResult
|
||||
@@ -50,14 +53,19 @@ func TestConnectTargetWithSshCli(t *testing.T) {
|
||||
t.Logf("Created Credentials: %s", newCredentialsId)
|
||||
|
||||
// Add credentials to target
|
||||
output = e2e.RunCommand(ctx, "boundary", "targets", "add-credential-sources",
|
||||
"-id", newTargetId,
|
||||
"-brokered-credential-source", newCredentialsId,
|
||||
output = e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"targets", "add-credential-sources",
|
||||
"-id", newTargetId,
|
||||
"-brokered-credential-source", newCredentialsId,
|
||||
),
|
||||
)
|
||||
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)
|
||||
@@ -74,11 +82,14 @@ func TestConnectTargetWithSshCli(t *testing.T) {
|
||||
t.Log("Successfully retrieved credentials for target")
|
||||
|
||||
// Connect to target and print host's IP address using retrieved credentials
|
||||
output = e2e.RunCommand(ctx, "boundary", "connect", "ssh",
|
||||
"-target-id", newTargetId, "--",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
|
||||
output = e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"connect", "ssh",
|
||||
"-target-id", newTargetId, "--",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
|
||||
),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
t.Log("Successfully connected to target")
|
||||
|
||||
Reference in new issue
Block a user