package gitea import ( "net" "testing" "gitea.weiker.me/rodin/review-bot/internal/netutil" ) // TestIsBlockedIPForwarding verifies that gitea.IsBlockedIP correctly forwards // to internal/netutil.IsBlockedIP. Full coverage of the blocking logic lives in // internal/netutil/ipcheck_test.go. func TestIsBlockedIPForwarding(t *testing.T) { cases := []struct { ip string blocked bool }{ {"127.0.0.1", true}, // loopback — must be blocked {"192.168.1.1", true}, // RFC1918 — must be blocked {"8.8.8.8", false}, // public — must not be blocked {"2001:4860:4860::8888", false}, // public IPv6 — must not be blocked } for _, tc := range cases { ip := net.ParseIP(tc.ip) if ip == nil { t.Fatalf("failed to parse IP %q", tc.ip) } got := IsBlockedIP(ip) want := netutil.IsBlockedIP(ip) if got != want { t.Errorf("gitea.IsBlockedIP(%q) = %v, netutil.IsBlockedIP = %v: forwarding mismatch", tc.ip, got, want) } if got != tc.blocked { t.Errorf("gitea.IsBlockedIP(%q) = %v, want %v", tc.ip, got, tc.blocked) } } }