test(e2e): Address issue when password starts with @ (#6358)

(cherry picked from commit 00e6359b59d798dd988445f92e49f4fa8409b2b8)
This commit is contained in:
Michael Li authored and GitHub committed 2026-01-22 10:55:40 -05:00
1 parent 06b46985b7
commit a7688470dd
1 file changed
+11 -5
+11 -5
View File
@@ -294,14 +294,17 @@ func CreateKvPasswordCredential(t testing.TB, secretPath string, user string, pr
require.NoError(t, err)
}
// Escape '@' in the password. Vault CLI interprets '@' as a file
escapedPassword := strings.ReplaceAll(password, "@", "\\@")
// Create secret
output := e2e.RunCommand(context.Background(), "vault",
e2e.WithArgs(
"kv", "put",
"-mount", secretPath,
secretName,
"username="+user,
"password="+password,
fmt.Sprintf("username=%s", user),
fmt.Sprintf("password=%s", escapedPassword),
),
)
require.NoError(t, output.Err, string(output.Stderr))
@@ -338,15 +341,18 @@ func CreateKvPasswordDomainCredential(t testing.TB, secretPath string, user stri
require.NoError(t, err)
}
// Escape '@' in the password. Vault CLI interprets '@' as a file
escapedPassword := strings.ReplaceAll(password, "@", "\\@")
// Create secret
output := e2e.RunCommand(context.Background(), "vault",
e2e.WithArgs(
"kv", "put",
"-mount", secretPath,
secretName,
"username="+user,
"password="+password,
"domain="+domain,
fmt.Sprintf("username=%s", user),
fmt.Sprintf("password=%s", escapedPassword),
fmt.Sprintf("domain=%s", domain),
),
)
require.NoError(t, output.Err, string(output.Stderr))