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
|
package generate
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestShouldMask(t *testing.T) {
tests := []struct {
mask string
unmask []string
shouldMask bool
}{
{"/proc/foo", []string{"all"}, false},
{"/proc/foo", []string{"ALL"}, false},
{"/proc/foo", []string{"/proc/foo"}, false},
{"/proc/foo", []string{"/proc/*"}, false},
{"/proc/foo", []string{"/proc/bar", "all"}, false},
{"/proc/foo", []string{"/proc/f*"}, false},
{"/proc/foo", []string{"/proc/b*"}, true},
{"/proc/foo", []string{}, true},
}
for _, test := range tests {
val := shouldMask(test.mask, test.unmask)
assert.Equal(t, val, test.shouldMask)
}
}
|