package relayurl import "testing" // The list is the union of every malformed value that reached a real node: the two that were written // into a config and refused only at the next startup, and the ones the transport already refused. func TestValidateRefusesWhatTheDaemonCannotUse(t *testing.T) { for _, raw := range []string{ "", // the flag was never given a value "relay.example", // no scheme: url.Parse reads this as a path "http://relay.example", // plaintext, so the ciphertext above it is decorative "ws://relay.example", // a scheme the transport cannot dial "https://relay.example/v1", // a path the request builder would silently append to "https://relay.example?x=1", "https://relay.example#f", "https://user:pw@relay.example", "https://", // no host "not a url", // a space is not a valid URL byte } { if err := Validate(raw); err == nil { t.Fatalf("accepted %q", raw) } } } func TestValidateAcceptsTheFormsAnOperatorActuallyTypes(t *testing.T) { for _, raw := range []string{ "https://relay.example", "https://relay.example/", // a trailing slash is trimmed by the transport, not an error "https://relay.example:8443", "https://203.0.113.9", } { if err := Validate(raw); err != nil { t.Fatalf("refused %q: %v", raw, err) } } }