Skip to content

Commit 52e2906

Browse files
author
Jamario Rankins
committed
Inital Commit
1 parent 9d1041e commit 52e2906

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

utils/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package utils
2+
3+
import "strings"
4+
5+
func Redact(token string) string {
6+
str := token[4 : len(token)-3]
7+
redaction := strings.Repeat("*", len(str))
8+
return string(token[:4]) + redaction + string(token[len(token)-3:])
9+
}

utils/utils_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package utils
2+
3+
import (
4+
"testing"
5+
6+
"github.com/exercism/cli/utils"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestRedact(t *testing.T) {
11+
fakeToken := "1a11111aaaa111aa1a11111a11111aa1"
12+
expected := "1a11*************************aa1"
13+
14+
assert.Equal(t, expected, utils.Redact(fakeToken))
15+
}

0 commit comments

Comments
 (0)