Skip to content

Commit

Permalink
added NoTLS test
Browse files Browse the repository at this point in the history
  • Loading branch information
diptadas committed May 9, 2018
1 parent 70a6848 commit 4098980
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions test/e2e/tcp-sni.go
@@ -1,6 +1,8 @@
package e2e

import (
"net/http"

core_util "github.com/appscode/kutil/core/v1"
api "github.com/appscode/voyager/apis/voyager/v1beta1"
"github.com/appscode/voyager/test/framework"
Expand All @@ -10,7 +12,6 @@ import (
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"net/http"
)

var _ = Describe("Ingress TCP SNI", func() {
Expand Down Expand Up @@ -125,6 +126,81 @@ var _ = Describe("Ingress TCP SNI", func() {
})
})

Describe("With NoTLS and Spec.TLS", func() {
BeforeEach(func() {
var err error
secret, err = f.Ingress.CreateTLSSecretForHost(f.UniqueName(), []string{domain})
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
if options.Cleanup {
f.KubeClient.CoreV1().Secrets(secret.Namespace).Delete(secret.Name, &metav1.DeleteOptions{})
}
})
BeforeEach(func() {
ing.Spec.TLS = []api.IngressTLS{
{
Ref: &api.LocalTypedReference{
Kind: "Secret",
Name: secret.Name,
},
Hosts: []string{domain},
},
}
ing.Spec.Rules = []api.IngressRule{
{
Host: domain,
IngressRuleValue: api.IngressRuleValue{
TCP: &api.TCPIngressRuleValue{
NoTLS: true,
Port: intstr.FromInt(8443),
Backend: api.IngressBackend{
ServiceName: f.Ingress.TestServerHTTPSName(),
ServicePort: intstr.FromInt(443),
},
},
},
},
{
Host: wildcardDomain,
IngressRuleValue: api.IngressRuleValue{
TCP: &api.TCPIngressRuleValue{
Port: intstr.FromInt(8443),
Backend: api.IngressBackend{
ServiceName: f.Ingress.TestServerHTTPSName(),
ServicePort: intstr.FromInt(3443),
},
},
},
},
}
})

It("Should response based on Host", func() {
By("Getting HTTP endpoints")
eps, err := f.Ingress.GetHTTPEndpoints(ing)
Expect(err).NotTo(HaveOccurred())
Expect(len(eps)).Should(BeNumerically(">=", 1))

svc, err := f.Ingress.GetOffShootService(ing)
Expect(err).NotTo(HaveOccurred())
Expect(len(svc.Spec.Ports)).Should(Equal(1))
Expect(svc.Spec.Ports[0].Port).To(Equal(int32(8443)))

By("Request with host: voyager.appscode.test")
err = f.Ingress.DoHTTPWithSNI(framework.MaxRetry, domain, eps, func(r *client.Response) bool {
return Expect(r.ServerPort).Should(Equal(":6443"))
})
Expect(err).NotTo(HaveOccurred())

By("Request with host: http.appscode.test") // matches wildcard domain
err = f.Ingress.DoHTTPWithSNI(framework.MaxRetry, "http.appscode.test", eps, func(r *client.Response) bool {
return Expect(r.ServerPort).Should(Equal(":3443"))
})
Expect(err).NotTo(HaveOccurred())
})
})

Describe("With TLS", func() {
BeforeEach(func() {
var err error
Expand Down Expand Up @@ -209,7 +285,7 @@ var _ = Describe("Ingress TCP SNI", func() {
Expect(err).NotTo(HaveOccurred())
})
})

Describe("SSL Passthrough", func() {
BeforeEach(func() {
ing.Annotations[api.SSLPassthrough] = "true"
Expand Down

0 comments on commit 4098980

Please sign in to comment.