MCPcopy Create free account
hub / github.com/docker/secrets-engine / TestPatternIncludes

Function TestPatternIncludes

x/secrets/pattern_test.go:68–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestPatternIncludes(t *testing.T) {
69 tests := []struct {
70 pattern string
71 other string
72 otherIsIncluded bool
73 }{
74 {"**", "**", true},
75 {"**/*", "*/**", true},
76 // **/* and ** are equivalent because IDs are required to always have at least one component
77 {"**/*", "**", true},
78 {"**", "**/*", true},
79 {"**/**", "**/**", true},
80 {"**/*/**", "**/**", true},
81 {"**/*/*", "*/*/**", true},
82 {"**/*/*", "**", false},
83 {"**", "**/foo", true},
84 {"**/foo", "**", false},
85 {"**/foo", "**/foo", true},
86 {"foo/**", "**/foo", false},
87 {"**", "bar/**/foo", true},
88 {"**", "*/bar/**/foo", true},
89 {"*", "*", true},
90 {"*/foo", "*", false},
91 {"*", "*/foo", false},
92 {"docker/*/mcp/*", "docker/proj1/**", false},
93 {"docker/proj1/**", "docker/*/mcp/*", true},
94 {"docker/proj1/**", "docker/**/mcp/**", false},
95 {"docker/**", "docker/**/mcp/**", true},
96 }
97 for idx, tc := range tests {
98 t.Run(fmt.Sprintf("pattern %d", idx+1), func(t *testing.T) {
99 p, err := ParsePattern(tc.pattern)
100 require.NoError(t, err)
101 other, err := ParsePattern(tc.other)
102 require.NoError(t, err)
103 assert.Equal(t, tc.otherIsIncluded, p.Includes(other))
104 })
105 }
106}
107
108func Test_Filter(t *testing.T) {
109 tests := []struct {

Callers

nothing calls this directly

Calls 3

ParsePatternFunction · 0.85
RunMethod · 0.65
IncludesMethod · 0.65

Tested by

no test coverage detected