Skip to content

Commit 4cd4e5e

Browse files
authored
fix(e2e-tests): ArgoCD E2E test logs print auth-token (argoproj#23696)
Signed-off-by: Atif Ali <atali@redhat.com>
1 parent 2e4af5f commit 4cd4e5e

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

test/e2e/fixture/cmd.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ func RunWithStdin(stdin, workDir, name string, args ...string) (string, error) {
2222

2323
return argoexec.RunCommandExt(cmd, argoexec.CmdOpts{})
2424
}
25+
26+
func RunWithStdinWithRedactor(stdin, workDir, name string, redactor func(string) string, args ...string) (string, error) {
27+
cmd := exec.Command(name, args...)
28+
if stdin != "" {
29+
cmd.Stdin = strings.NewReader(stdin)
30+
}
31+
cmd.Env = os.Environ()
32+
cmd.Dir = workDir
33+
34+
return argoexec.RunCommandExt(cmd, argoexec.CmdOpts{Redactor: redactor})
35+
}

test/e2e/fixture/fixture.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,18 @@ func RunCliWithStdin(stdin string, isKubeConextOnlyCli bool, args ...string) (st
10451045

10461046
args = append(args, "--insecure")
10471047

1048-
return RunWithStdin(stdin, "", "../../dist/argocd", args...)
1048+
// Create a redactor that only redacts the auth token value
1049+
redactor := func(text string) string {
1050+
if token == "" {
1051+
return text
1052+
}
1053+
// Use a more precise approach to only redact the exact auth token
1054+
// Look for --auth-token followed by the exact token value
1055+
authTokenPattern := "--auth-token " + token
1056+
return strings.ReplaceAll(text, authTokenPattern, "--auth-token ******")
1057+
}
1058+
1059+
return RunWithStdinWithRedactor(stdin, "", "../../dist/argocd", redactor, args...)
10491060
}
10501061

10511062
// RunPluginCli executes an Argo CD CLI plugin with optional stdin input.

0 commit comments

Comments
 (0)