Skip to content

Commit

Permalink
Add \r\n multiline test
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJosh9000 committed Oct 23, 2024
1 parent 3c8709a commit f77a791
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/replacer/replacer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,27 @@ func TestReplacerMultiLine(t *testing.T) {
}
}

func TestReplacerMultiLineCrLf(t *testing.T) {
t.Parallel()

var buf strings.Builder

replacer := replacer.New(&buf, []string{"-----BEGIN OPENSSH PRIVATE KEY-----\nasdf\n-----END OPENSSH PRIVATE KEY-----\n"}, redact.Redact)

fmt.Fprint(replacer, "lalalala\r\n")
fmt.Fprint(replacer, "-----BEGIN OPENSSH PRIVATE KEY-----\r\n")
fmt.Fprint(replacer, "asdf\r\n")
fmt.Fprint(replacer, "-----END OPENSSH PRIVATE KEY-----\r\n")
fmt.Fprint(replacer, "lalalala\r\n")
replacer.Flush()

want := "lalalala\r\n[REDACTED]lalalala\r\n"

if diff := cmp.Diff(buf.String(), want); diff != "" {
t.Errorf("post-redaction diff (-got +want):\n%s", diff)
}
}

func TestAddingNeedles(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit f77a791

Please sign in to comment.