forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_helpers_test.go
56 lines (52 loc) · 915 Bytes
/
plugin_helpers_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package api
import "testing"
func TestIsSudoPath(t *testing.T) {
t.Parallel()
testCases := []struct {
path string
expected bool
}{
{
"/not/in/sudo/paths/list",
false,
},
{
"/sys/raw/single-node-path",
true,
},
{
"/sys/raw/multiple/nodes/path",
true,
},
{
"/sys/raw/WEIRD(but_still_valid!)p4Th?🗿笑",
true,
},
{
"/sys/auth/path/in/middle/tune",
true,
},
{
"/sys/plugins/catalog/some-type",
true,
},
{
"/sys/plugins/catalog/some/type/or/name/with/slashes",
false,
},
{
"/sys/plugins/catalog/some-type/some-name",
true,
},
{
"/sys/plugins/catalog/some-type/some/name/with/slashes",
false,
},
}
for _, tc := range testCases {
result := IsSudoPath(tc.path)
if result != tc.expected {
t.Fatalf("expected api.IsSudoPath to return %v for path %s but it returned %v", tc.expected, tc.path, result)
}
}
}