From f3d44ba81785107e02127a5199b1fbb3abc6a91e Mon Sep 17 00:00:00 2001 From: Tony <52470376+wongtonyb@users.noreply.github.com> Date: Tue, 11 Nov 2025 13:07:11 -0500 Subject: [PATCH] chore(e2e): update vault create credential funcs (#6239) --- testing/internal/e2e/vault/vault.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/testing/internal/e2e/vault/vault.go b/testing/internal/e2e/vault/vault.go index c021422a69..4284494337 100644 --- a/testing/internal/e2e/vault/vault.go +++ b/testing/internal/e2e/vault/vault.go @@ -270,7 +270,7 @@ func CreateKvPrivateKeyCredential(t testing.TB, secretPath string, user string, // this function does not put any clean-up in place to run after a test is // complete. When applicable, callers should destroy the policy and secret this // function creates. -func CreateKvPasswordCredential(t testing.TB, secretPath string, user string) (secretName string, policyName string, password string) { +func CreateKvPasswordCredential(t testing.TB, secretPath string, user string, providedPassword ...string) (secretName string, policyName string, password string) { secretName, err := base62.Random(16) require.NoError(t, err) @@ -286,9 +286,15 @@ func CreateKvPasswordCredential(t testing.TB, secretPath string, user string) (s policyName = WritePolicy(t, t.Context(), policyFilePath) + // Use provided password or generate random one + if len(providedPassword) > 0 && providedPassword[0] != "" { + password = providedPassword[0] + } else { + password, err = base62.Random(16) + require.NoError(t, err) + } + // Create secret - password, err = base62.Random(16) - require.NoError(t, err) output := e2e.RunCommand(context.Background(), "vault", e2e.WithArgs( "kv", "put", @@ -308,7 +314,7 @@ func CreateKvPasswordCredential(t testing.TB, secretPath string, user string) (s // credential. Returns the name of the policy. Note that this function does not // put any clean-up in place to run after a test is complete. When applicable, // callers should destroy the policy and secret this function creates. -func CreateKvPasswordDomainCredential(t testing.TB, secretPath string, user string, domain string) (secretName string, policyName string, password string) { +func CreateKvPasswordDomainCredential(t testing.TB, secretPath string, user string, domain string, providedPassword ...string) (secretName string, policyName string, password string) { secretName, err := base62.Random(16) require.NoError(t, err) @@ -324,9 +330,15 @@ func CreateKvPasswordDomainCredential(t testing.TB, secretPath string, user stri policyName = WritePolicy(t, t.Context(), policyFilePath) + // Use provided password or generate random one + if len(providedPassword) > 0 && providedPassword[0] != "" { + password = providedPassword[0] + } else { + password, err = base62.Random(16) + require.NoError(t, err) + } + // Create secret - password, err = base62.Random(16) - require.NoError(t, err) output := e2e.RunCommand(context.Background(), "vault", e2e.WithArgs( "kv", "put",