forked from exercism/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jamario Rankins
committed
Aug 2, 2019
1 parent
9d1041e
commit 52e2906
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
func Redact(token string) string { | ||
str := token[4 : len(token)-3] | ||
redaction := strings.Repeat("*", len(str)) | ||
return string(token[:4]) + redaction + string(token[len(token)-3:]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/exercism/cli/utils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRedact(t *testing.T) { | ||
fakeToken := "1a11111aaaa111aa1a11111a11111aa1" | ||
expected := "1a11*************************aa1" | ||
|
||
assert.Equal(t, expected, utils.Redact(fakeToken)) | ||
} |