fix
This commit is contained in:
@@ -134,3 +134,17 @@ func TestGateAllowsPublicFlagInProduction(t *testing.T) {
|
||||
t.Fatalf("METRICS_PUBLIC status=%d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGateBlocksSpoofedLoopbackXFFInProduction(t *testing.T) {
|
||||
t.Cleanup(Reset)
|
||||
Reset()
|
||||
h := Gate(true, false)(Handler())
|
||||
req := httptest.NewRequest(http.MethodGet, "/metrics", nil)
|
||||
req.RemoteAddr = "127.0.0.1:54321"
|
||||
req.Header.Set("X-Forwarded-For", "127.0.0.1")
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusNotFound {
|
||||
t.Fatalf("spoofed XFF loopback status=%d want 404", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user