package labeler import "testing" // TestIsLocalhost covers the OAuth-mode decision: any IP-literal host (including // docker-compose private addresses like 172.28.0.x and the standard 127.0.0.1) plus // the literal "localhost" routes through the loopback OAuth path so PDSes don't have // to fetch our published client metadata. Domain names go through the public-client // path and require the metadata endpoint to be reachable from the PDS. func TestIsLocalhost(t *testing.T) { tests := []struct { host string want bool }{ {"localhost", true}, {"127.0.0.1", true}, {"::1", true}, {"192.168.1.10", true}, {"172.28.0.4", true}, // docker-compose private network {"10.0.0.5", true}, // RFC 1918 {"labeler.atcr.io", false}, {"labeler.example.com", false}, {"", false}, } for _, tt := range tests { if got := isLocalhost(tt.host); got != tt.want { t.Errorf("isLocalhost(%q) = %v, want %v", tt.host, got, tt.want) } } }