-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
sensitive_test.go
41 lines (37 loc) · 1.19 KB
/
sensitive_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.
package utils
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestHideSensitive(t *testing.T) {
strs := []struct {
old string
new string
}{
{
`host = "127.0.0.1"\n user = "root"\n password = "/Q7B9DizNLLTTfiZHv9WoEAKamfpIUs="\n port = 3306\n`,
`host = "127.0.0.1"\n user = "root"\n password = ******\n port = 3306\n`,
},
{
`host = "127.0.0.1"\n user = "root"\n password = ""\n port = 3306\n`,
`host = "127.0.0.1"\n user = "root"\n password = ******\n port = 3306\n`,
},
{
`host = "127.0.0.1"\n user = "root"\n password= "/Q7B9DizNLLTTfiZHv9WoEAKamfpIUs="\n port = 3306\n`,
`host = "127.0.0.1"\n user = "root"\n password= ******\n port = 3306\n`,
},
{
`host = "127.0.0.1"\n user = "root"\n password =""\n port = 3306\n`,
`host = "127.0.0.1"\n user = "root"\n password =******\n port = 3306\n`,
},
{
`host = "127.0.0.1"\n user = "root"\n password=""\n port = 3306\n`,
`host = "127.0.0.1"\n user = "root"\n password=******\n port = 3306\n`,
},
}
for i, str := range strs {
t.Logf("case #%d\n", i)
require.Equal(t, str.new, HideSensitive(str.old))
}
}