MCPcopy Create free account
hub / github.com/cloudflare/cfssl / TestNewServer

Function TestNewServer

api/client/client_test.go:18–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNewServer(t *testing.T) {
19 s := NewServer("1.1.1.1:::123456789")
20 if s != nil {
21 t.Fatalf("fatal error, server created with too many colons %v", s)
22 }
23
24 s2 := NewServer("1.1.1.1:[]")
25 if s != nil {
26 t.Fatalf("%v", s2)
27
28 }
29
30 _, port, _ := net.SplitHostPort("")
31 if port != "" {
32 t.Fatalf("%v", port)
33
34 }
35
36 s = NewServer("http://127.0.0.1:8888")
37 hosts := s.Hosts()
38 if len(hosts) != 1 || hosts[0] != "http://127.0.0.1:8888" {
39 t.Fatalf("expected [http://127.0.0.1:8888], but have %v", hosts)
40 }
41
42 s = NewServer("http://1.1.1.1:9999")
43 hosts = s.Hosts()
44 if len(hosts) != 1 || hosts[0] != "http://1.1.1.1:9999" {
45 t.Fatalf("expected [http://1.1.1.1:9999], but have %v", hosts)
46 }
47
48 s = NewServer("https://1.1.1.1:8080")
49 hosts = s.Hosts()
50 if len(hosts) != 1 || hosts[0] != "https://1.1.1.1:8080" {
51 t.Fatalf("expected [https://1.1.1.1:8080], but have %v", hosts)
52 }
53}
54
55func TestInvalidPort(t *testing.T) {
56 s := NewServer("1.1.1.1:99999999999999999999999999999")

Callers

nothing calls this directly

Calls 2

NewServerFunction · 0.85
HostsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…