MCPcopy Index your code
hub / github.com/github/gh-aw / TestSpec_PublicAPI_SanitizeErrorMessage

Function TestSpec_PublicAPI_SanitizeErrorMessage

pkg/stringutil/spec_test.go:580–604  ·  view source on GitHub ↗

TestSpec_PublicAPI_SanitizeErrorMessage validates the documented behavior of SanitizeErrorMessage as described in the package README.md. Specification: "Redacts potential secret key names from error messages. Matches uppercase SNAKE_CASE identifiers (e.g. MY_SECRET_KEY, API_TOKEN) and PascalCase id

(t *testing.T)

Source from the content-addressed store, hash-verified

578// stringutil.SanitizeErrorMessage("Error: MY_SECRET_TOKEN is invalid")
579// // → "Error: [REDACTED] is invalid"
580func TestSpec_PublicAPI_SanitizeErrorMessage(t *testing.T) {
581 t.Run("redacts SNAKE_CASE secret (documented example)", func(t *testing.T) {
582 result := SanitizeErrorMessage("Error: MY_SECRET_TOKEN is invalid")
583 assert.Equal(t, "Error: [REDACTED] is invalid", result,
584 "SanitizeErrorMessage should redact SNAKE_CASE secret identifiers")
585 })
586
587 // Specification: PascalCase identifiers ending with security-related suffixes
588 // (e.g. GitHubToken, ApiKey) are redacted.
589 t.Run("redacts PascalCase identifier ending with security suffix", func(t *testing.T) {
590 result := SanitizeErrorMessage("error: ApiKey not found")
591 assert.Contains(t, result, "[REDACTED]",
592 "SanitizeErrorMessage should redact PascalCase identifiers ending with security suffixes")
593 })
594
595 // Specification: "Common GitHub Actions workflow keywords (GITHUB, RUNNER,
596 // WORKFLOW, etc.) are excluded from redaction."
597 // Standalone keywords like "GITHUB" don't match the compound pattern which
598 // requires underscores, so they pass through unchanged.
599 t.Run("does not redact standalone GITHUB keyword", func(t *testing.T) {
600 result := SanitizeErrorMessage("Error: GITHUB is not responding")
601 assert.NotContains(t, result, "[REDACTED]",
602 "SanitizeErrorMessage should not redact standalone GITHUB keyword")
603 })
604}
605
606// TestSpec_Constants_PATType validates the documented PATType constant values
607// as described in the package README.md.

Callers

nothing calls this directly

Calls 2

SanitizeErrorMessageFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected