package proxy import "testing" func TestValidateURL(t *testing.T) { for _, tc := range []struct { raw string ok bool }{ {"https://example.com/a", true}, {"file:///etc/passwd", false}, {"http://169.254.169.254/latest/meta-data", false}, {"http://metadata.google.internal/computeMetadata/v1", false}, } { _, err := ValidateURL(tc.raw) if tc.ok && err != nil { t.Fatalf("%s: %v", tc.raw, err) } if !tc.ok && err == nil { t.Fatalf("expected rejection: %s", tc.raw) } } }