(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func 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 | } |
nothing calls this directly
no test coverage detected