MCPcopy
hub / github.com/yusing/godoxy / TestNewDockerHandler_PathHandling

Function TestNewDockerHandler_PathHandling

socket-proxy/pkg/handler_test.go:228–395  ·  view source on GitHub ↗

This test focuses on checking that all the path prefix handling works correctly

(t *testing.T)

Source from the content-addressed store, hash-verified

226
227// This test focuses on checking that all the path prefix handling works correctly
228func TestNewDockerHandler_PathHandling(t *testing.T) {
229 tests := []struct {
230 name string
231 path string
232 envVarName string
233 envVarValue bool
234 method string
235 wantAllowed bool
236 }{
237 {"Container path", "/containers/json", "DockerContainers", true, http.MethodGet, true},
238 {"Container path disabled", "/containers/json", "DockerContainers", false, http.MethodGet, false},
239
240 {"Auth path", "/auth", "DockerAuth", true, http.MethodGet, true},
241 {"Auth path disabled", "/auth", "DockerAuth", false, http.MethodGet, false},
242
243 {"Build path", "/build", "DockerBuild", true, http.MethodGet, true},
244 {"Build path disabled", "/build", "DockerBuild", false, http.MethodGet, false},
245
246 {"Commit path", "/commit", "DockerCommit", true, http.MethodGet, true},
247 {"Commit path disabled", "/commit", "DockerCommit", false, http.MethodGet, false},
248
249 {"Configs path", "/configs", "DockerConfigs", true, http.MethodGet, true},
250 {"Configs path disabled", "/configs", "DockerConfigs", false, http.MethodGet, false},
251
252 {"Distribution path", "/distribution", "DockerDistribution", true, http.MethodGet, true},
253 {"Distribution path disabled", "/distribution", "DockerDistribution", false, http.MethodGet, false},
254
255 {"Events path", "/events", "DockerEvents", true, http.MethodGet, true},
256 {"Events path disabled", "/events", "DockerEvents", false, http.MethodGet, false},
257
258 {"Exec path", "/exec", "DockerExec", true, http.MethodGet, true},
259 {"Exec path disabled", "/exec", "DockerExec", false, http.MethodGet, false},
260
261 {"Grpc path", "/grpc", "DockerGrpc", true, http.MethodGet, true},
262 {"Grpc path disabled", "/grpc", "DockerGrpc", false, http.MethodGet, false},
263
264 {"Images path", "/images", "DockerImages", true, http.MethodGet, true},
265 {"Images path disabled", "/images", "DockerImages", false, http.MethodGet, false},
266
267 {"Info path", "/info", "DockerInfo", true, http.MethodGet, true},
268 {"Info path disabled", "/info", "DockerInfo", false, http.MethodGet, false},
269
270 {"Networks path", "/networks", "DockerNetworks", true, http.MethodGet, true},
271 {"Networks path disabled", "/networks", "DockerNetworks", false, http.MethodGet, false},
272
273 {"Nodes path", "/nodes", "DockerNodes", true, http.MethodGet, true},
274 {"Nodes path disabled", "/nodes", "DockerNodes", false, http.MethodGet, false},
275
276 {"Plugins path", "/plugins", "DockerPlugins", true, http.MethodGet, true},
277 {"Plugins path disabled", "/plugins", "DockerPlugins", false, http.MethodGet, false},
278
279 {"Secrets path", "/secrets", "DockerSecrets", true, http.MethodGet, true},
280 {"Secrets path disabled", "/secrets", "DockerSecrets", false, http.MethodGet, false},
281
282 {"Services path", "/services", "DockerServices", true, http.MethodGet, true},
283 {"Services path disabled", "/services", "DockerServices", false, http.MethodGet, false},
284
285 {"Session path", "/session", "DockerSession", true, http.MethodGet, true},

Callers

nothing calls this directly

Calls 3

ServeHTTPMethod · 0.95
LoadFunction · 0.70
NewHandlerFunction · 0.70

Tested by

no test coverage detected