package outbound
import "testing"
// Whatever quarry sends on its own initiative goes over https, or over
// http only to this machine (#225).
func TestOnlyHTTPSLeavesTheMachine(t *testing.T) {
for _, tc := range []struct {
raw string
ok bool
}{
{"https://hooks.example/x", true},
{"http://127.0.0.1:8950/r/quarry", true},
{"http://localhost:9000", true},
{"http://[::1]:9000", true},
{"http://hooks.example/x", false},
{"http://127.evil.example/x", false},
{"http://10.0.0.5/x", false},
{"ftp://files.example/x", false},
{"https:///nohost", false},
{"not a url", false},
} {
_, err := Check(tc.raw)
if (err == nil) != tc.ok {
t.Errorf("FAIL: %q accepted=%v, want %v (%v)", tc.raw, err == nil, tc.ok, err)
} else {
t.Logf("ok: %q accepted=%v", tc.raw, tc.ok)
}
}
}