MCPcopy
hub / github.com/caddyserver/caddy / TestFileMatcherNonWindows

Function TestFileMatcherNonWindows

modules/caddyhttp/fileserver/matcher_test.go:128–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestFileMatcherNonWindows(t *testing.T) {
129 if runtime.GOOS == "windows" {
130 return
131 }
132
133 // this is impossible to test on Windows, but tests a security patch for other platforms
134 tc := testCase{
135 path: "/foodir/secr%5Cet.txt",
136 expectedPath: "/foodir/secr\\et.txt",
137 expectedType: "file",
138 matched: true,
139 }
140
141 f, err := os.Create(filepath.Join("testdata", strings.TrimPrefix(tc.expectedPath, "/")))
142 if err != nil {
143 t.Fatalf("could not create test file: %v", err)
144 }
145 defer f.Close()
146 defer os.Remove(f.Name())
147
148 fileMatcherTest(t, 0, tc)
149}
150
151func fileMatcherTest(t *testing.T, i int, tc testCase) {
152 m := &MatchFile{

Callers

nothing calls this directly

Calls 3

fileMatcherTestFunction · 0.85
CloseMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected