| 154 | } |
| 155 | |
| 156 | func TestRedactPasswordEnvVar(t *testing.T) { |
| 157 | t.Parallel() |
| 158 | cases := []struct { |
| 159 | name string |
| 160 | input string |
| 161 | }{ |
| 162 | {"PASSWORD", "PASSWORD=hunter2"}, |
| 163 | {"SECRET", "SECRET=mysecretvalue"}, |
| 164 | {"TOKEN", "TOKEN=abc123xyz"}, |
| 165 | } |
| 166 | for _, tc := range cases { |
| 167 | t.Run(tc.name, func(t *testing.T) { |
| 168 | got := Text(tc.input) |
| 169 | if !strings.Contains(got, "[REDACTED CREDENTIAL]") { |
| 170 | t.Fatalf("expected credential redaction for %s, got: %s", tc.name, got) |
| 171 | } |
| 172 | }) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func TestInputMap(t *testing.T) { |
| 177 | t.Parallel() |