Skip to content

Commit

Permalink
unit test for redactions
Browse files Browse the repository at this point in the history
  • Loading branch information
almadireddy committed Aug 8, 2019
1 parent d6a641c commit 5030635
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"bytes"
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -24,3 +26,10 @@ func TestEnvironRun(t *testing.T) {
assert.Equal(t, "", stderr.String())
}
}

func TestRedaction(t *testing.T) {
arg := "--oauth2_access_token hello -E CREDENTIALS:{\n \"name\": \"nameVal\", \n \"name\": \n \"nameVal\", \n \"name\": \"nameVal\"\n }"
redacted := reRedact.ReplaceAllString(strings.Trim(fmt.Sprint(arg), "[]"), " $1 [redacted]")

assert.Equal(t, " --oauth2_access_token [redacted] -E CREDENTIALS: [redacted]", redacted)
}

0 comments on commit 5030635

Please sign in to comment.