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
@@ -39,12 +39,17 @@ func Setup(t testing.TB) (string, string) {
|
||||
require.True(t, ok)
|
||||
ctx := context.Background()
|
||||
policyName := "boundary-controller"
|
||||
output := e2e.RunCommand(ctx, "vault", "policy", "write", policyName,
|
||||
path.Join(path.Dir(filename), "boundary-controller-policy.hcl"),
|
||||
output := e2e.RunCommand(ctx, "vault",
|
||||
e2e.WithArgs(
|
||||
"policy", "write", policyName,
|
||||
path.Join(path.Dir(filename), "boundary-controller-policy.hcl"),
|
||||
),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
t.Cleanup(func() {
|
||||
output := e2e.RunCommand(ctx, "vault", "policy", "delete", policyName)
|
||||
output := e2e.RunCommand(ctx, "vault",
|
||||
e2e.WithArgs("policy", "delete", policyName),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
})
|
||||
|
||||
@@ -69,19 +74,26 @@ func CreateKvPrivateKeyCredential(t testing.TB, secretName string, secretPath st
|
||||
// Add policy to vault
|
||||
ctx := context.Background()
|
||||
policyName := "kv-read"
|
||||
output := e2e.RunCommand(ctx, "vault", "policy", "write", policyName, kvPolicyFilePath)
|
||||
output := e2e.RunCommand(ctx, "vault",
|
||||
e2e.WithArgs("policy", "write", policyName, kvPolicyFilePath),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
t.Cleanup(func() {
|
||||
output := e2e.RunCommand(ctx, "vault", "policy", "delete", policyName)
|
||||
output := e2e.RunCommand(ctx, "vault",
|
||||
e2e.WithArgs("policy", "delete", policyName),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
})
|
||||
|
||||
// Create secret
|
||||
output = e2e.RunCommand(ctx, "vault", "kv", "put",
|
||||
"-mount", secretPath,
|
||||
secretName,
|
||||
"username="+user,
|
||||
"private_key=@"+keyPath,
|
||||
output = e2e.RunCommand(ctx, "vault",
|
||||
e2e.WithArgs(
|
||||
"kv", "put",
|
||||
"-mount", secretPath,
|
||||
secretName,
|
||||
"username="+user,
|
||||
"private_key=@"+keyPath,
|
||||
),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
|
||||
|
||||
Reference in new issue
Block a user