MCPcopy Create free account
hub / github.com/github/gh-aw / TestLoggingHandler_SanitizesPath

Function TestLoggingHandler_SanitizesPath

pkg/cli/mcp_server_http_test.go:97–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestLoggingHandler_SanitizesPath(t *testing.T) {
98 // The handler should not panic on paths with newlines/carriage returns
99 inner := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
100 w.WriteHeader(http.StatusOK)
101 })
102
103 handler := loggingHandler(inner)
104
105 // Path with newline injection attempt (Go's http package strips these, but test sanitize logic)
106 req := httptest.NewRequest(http.MethodGet, "/safe-path", nil)
107 rec := httptest.NewRecorder()
108
109 // Should not panic
110 handler.ServeHTTP(rec, req)
111
112 if rec.Code != http.StatusOK {
113 t.Errorf("response code = %d, want %d", rec.Code, http.StatusOK)
114 }
115}

Callers

nothing calls this directly

Calls 2

loggingHandlerFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected