Download this file
| 1 | package websource_test |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/runnerproto" |
| 8 | "amadan.net/oficina/equipo/internal/websource" |
| 9 | ) |
| 10 | |
| 11 | // Whatever the runner's redaction hides, a proposal may not carry. |
| 12 | func TestLooksSecretCoversRedaction(t *testing.T) { |
| 13 | for _, s := range []string{ |
| 14 | "/x/token=abcdef1234", "/x/api_key:abcdef", "/x/password=hunter2", "/sk-abcdefgh1234", |
| 15 | "/ghp_abcdefgh12345678", "/github_pat_abcdefgh12345678", "/eyJhbGciOi.eyJzdWIiOi.c2ln", |
| 16 | "/" + strings.Repeat("Ab1", 14), |
| 17 | } { |
| 18 | if runnerproto.RedactDetail(s, 1000) == s { |
| 19 | t.Fatalf("sample %q is not redacted; pick another", s) |
| 20 | } |
| 21 | if !websource.LooksSecret(s) { |
| 22 | t.Errorf("redaction hides %q but LooksSecret misses it", s) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |