@@ -99,4 +99,45 @@ var _ = Describe("Validator suite", func() {
9999 Entry("Partial Subdomain", "evilbar.foo", false),
100100 )
101101 })
102+
103+ Context("SplitHostPort", func() {
104+ type splitHostPortTableInput struct {
105+ hostport string
106+ expectedHost string
107+ expectedPort string
108+ }
109+
110+ DescribeTable("Should split the host and port",
111+ func(in splitHostPortTableInput) {
112+ host, port := splitHostPort(in.hostport)
113+ Expect(host).To(Equal(in.expectedHost))
114+ Expect(port).To(Equal(in.expectedPort))
115+ },
116+ Entry("when no port is specified", splitHostPortTableInput{
117+ hostport: "foo.bar",
118+ expectedHost: "foo.bar",
119+ expectedPort: "",
120+ }),
121+ Entry("with a valid port specified", splitHostPortTableInput{
122+ hostport: "foo.bar:8080",
123+ expectedHost: "foo.bar",
124+ expectedPort: "8080",
125+ }),
126+ Entry("with an invalid port specified", splitHostPortTableInput{
127+ hostport: "foo.bar:808a",
128+ expectedHost: "foo.bar:808a",
129+ expectedPort: "",
130+ }),
131+ Entry("with a wildcard port specified", splitHostPortTableInput{
132+ hostport: "foo.bar:*",
133+ expectedHost: "foo.bar",
134+ expectedPort: "*",
135+ }),
136+ Entry("when the host is specified with brackets", splitHostPortTableInput{
137+ hostport: "[foo.bar]",
138+ expectedHost: "foo.bar",
139+ expectedPort: "",
140+ }),
141+ )
142+ })
102143})