File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ package provider
2
+
3
+ import "testing"
4
+
5
+ func TestMatchStringWithMask (t * testing.T ) {
6
+ t .Parallel ()
7
+
8
+ testCases := []struct {
9
+ target string
10
+ mask string
11
+ expected bool
12
+ }{
13
+ {
14
+ target : "sk-my-secret-key" ,
15
+ mask : "sk-my-secret-key" ,
16
+ expected : true ,
17
+ },
18
+ {
19
+ target : "sk-my-secret-key" ,
20
+ mask : "sk-my-se************************************************************key" ,
21
+ expected : true ,
22
+ },
23
+ {
24
+ target : "sk-my-secret-key" ,
25
+ mask : "sk-my-*-key" ,
26
+ expected : true ,
27
+ },
28
+ {
29
+ target : "sk-my-secret-key" ,
30
+ mask : "sk-my-secret-key-2" ,
31
+ expected : false ,
32
+ },
33
+ {
34
+ target : "sk-my-secret-key" ,
35
+ mask : "sk-my-*-key-2" ,
36
+ expected : false ,
37
+ },
38
+ }
39
+
40
+ for _ , tc := range testCases {
41
+ t .Run (tc .target , func (t * testing.T ) {
42
+ actual := MatchStringWithMask (tc .target , tc .mask )
43
+ if actual != tc .expected {
44
+ t .Errorf ("expected %v, got %v" , tc .expected , actual )
45
+ }
46
+ })
47
+ }
48
+ }
You can’t perform that action at this time.
0 commit comments