INNER CODE UNIT · Go
TestConfigureTrustedProxiesIgnoresForwardedForFromUntrustedPeerByDefault
kite-org/kite · main_test.go:69
func TestConfigureTrustedProxiesIgnoresForwardedForFromUntrustedPeerByDefault(t *testing.T) {
if got := clientIPForForwardedRequest(t, nil, "198.51.100.10:12345", "127.0.0.1"); got == "127.0.0.1" {
t.Fatalf("ClientIP() trusted X-Forwarded-For from untrusted peer: got %q", got)
}
}
func TestConfigureTrustedProxiesUsesForwardedForFromDefaultPrivateProxy(t *testing.T) {
if got := clientIPForForwardedRequest(t, nil, "192.168.1.10:12345", "203.0.113.9"); got != "203.0.113.9" {
t.Fatalf("ClientIP() = %q, want forwarded client IP from default private proxy", got)
}
}
func TestConfigureTrustedProxiesUsesForwardedForFromTrustedProxy(t *testing.T) {
if got := clientIPForForwardedRequest(t, []string{"192.0.2.0/24"}, "192.0.2.10:12345", "203.0.113.9"); got != "203.0.113.9" {
t.Fatalf("ClientIP() = %q, want forwarded client IP", got)
}
}