Add tests for alias annotation
This commit is contained in:
parent
d4fd127a1f
commit
4c1c707e9c
10 changed files with 479 additions and 57 deletions
|
|
@ -39,14 +39,6 @@ var _ = framework.IngressNginxDescribe("Default backend", func() {
|
|||
})
|
||||
|
||||
It("should return 404 sending requests when only a default backend is running", func() {
|
||||
httpURL, err := f.GetNginxURL(framework.HTTP)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
httpsURL, err := f.GetNginxURL(framework.HTTPS)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
request := gorequest.New()
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
Host string
|
||||
|
|
@ -55,38 +47,39 @@ var _ = framework.IngressNginxDescribe("Default backend", func() {
|
|||
Path string
|
||||
Status int
|
||||
}{
|
||||
{"basic HTTP GET request without host to path / should return 404", "", framework.HTTP, "GET", "/", 404},
|
||||
{"basic HTTP GET request without host to path /demo should return 404", "", framework.HTTP, "GET", "/demo", 404},
|
||||
{"basic HTTPS GET request without host to path / should return 404", "", framework.HTTPS, "GET", "/", 404},
|
||||
{"basic HTTPS GET request without host to path /demo should return 404", "", framework.HTTPS, "GET", "/demo", 404},
|
||||
{"basic HTTP GET request without host to path / should return 404", "", framework.HTTP, "GET", "/", http.StatusNotFound},
|
||||
{"basic HTTP GET request without host to path /demo should return 404", "", framework.HTTP, "GET", "/demo", http.StatusNotFound},
|
||||
{"basic HTTPS GET request without host to path / should return 404", "", framework.HTTPS, "GET", "/", http.StatusNotFound},
|
||||
{"basic HTTPS GET request without host to path /demo should return 404", "", framework.HTTPS, "GET", "/demo", http.StatusNotFound},
|
||||
|
||||
{"basic HTTP POST request without host to path / should return 404", "", framework.HTTP, "POST", "/", 404},
|
||||
{"basic HTTP POST request without host to path /demo should return 404", "", framework.HTTP, "POST", "/demo", 404},
|
||||
{"basic HTTPS POST request without host to path / should return 404", "", framework.HTTPS, "POST", "/", 404},
|
||||
{"basic HTTPS POST request without host to path /demo should return 404", "", framework.HTTPS, "POST", "/demo", 404},
|
||||
{"basic HTTP POST request without host to path / should return 404", "", framework.HTTP, "POST", "/", http.StatusNotFound},
|
||||
{"basic HTTP POST request without host to path /demo should return 404", "", framework.HTTP, "POST", "/demo", http.StatusNotFound},
|
||||
{"basic HTTPS POST request without host to path / should return 404", "", framework.HTTPS, "POST", "/", http.StatusNotFound},
|
||||
{"basic HTTPS POST request without host to path /demo should return 404", "", framework.HTTPS, "POST", "/demo", http.StatusNotFound},
|
||||
|
||||
{"basic HTTP GET request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTP, "GET", "/", 404},
|
||||
{"basic HTTP GET request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTP, "GET", "/demo", 404},
|
||||
{"basic HTTPS GET request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTPS, "GET", "/", 404},
|
||||
{"basic HTTPS GET request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTPS, "GET", "/demo", 404},
|
||||
{"basic HTTP GET request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTP, "GET", "/", http.StatusNotFound},
|
||||
{"basic HTTP GET request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTP, "GET", "/demo", http.StatusNotFound},
|
||||
{"basic HTTPS GET request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTPS, "GET", "/", http.StatusNotFound},
|
||||
{"basic HTTPS GET request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTPS, "GET", "/demo", http.StatusNotFound},
|
||||
|
||||
{"basic HTTP POST request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTP, "POST", "/", 404},
|
||||
{"basic HTTP POST request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTP, "POST", "/demo", 404},
|
||||
{"basic HTTPS POST request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTPS, "POST", "/", 404},
|
||||
{"basic HTTPS POST request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTPS, "POST", "/demo", 404},
|
||||
{"basic HTTP POST request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTP, "POST", "/", http.StatusNotFound},
|
||||
{"basic HTTP POST request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTP, "POST", "/demo", http.StatusNotFound},
|
||||
{"basic HTTPS POST request to host foo.bar.com and path / should return 404", " foo.bar.com", framework.HTTPS, "POST", "/", http.StatusNotFound},
|
||||
{"basic HTTPS POST request to host foo.bar.com and path /demo should return 404", " foo.bar.com", framework.HTTPS, "POST", "/demo", http.StatusNotFound},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
By(test.Name)
|
||||
var errs []error
|
||||
|
||||
request := gorequest.New()
|
||||
var cm *gorequest.SuperAgent
|
||||
|
||||
switch test.Scheme {
|
||||
case framework.HTTP:
|
||||
cm = request.CustomMethod(test.Method, httpURL)
|
||||
cm = request.CustomMethod(test.Method, f.NginxHTTPURL)
|
||||
break
|
||||
case framework.HTTPS:
|
||||
cm = request.CustomMethod(test.Method, httpsURL)
|
||||
cm = request.CustomMethod(test.Method, f.NginxHTTPSURL)
|
||||
// the default backend uses a self generated certificate
|
||||
cm.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package defaultbackend
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
|
@ -37,36 +36,29 @@ var _ = framework.IngressNginxDescribe("Default backend - SSL", func() {
|
|||
})
|
||||
|
||||
It("should return a self generated SSL certificate", func() {
|
||||
httpsURL, err := f.GetNginxURL(framework.HTTPS)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
request := gorequest.New()
|
||||
|
||||
By("checking SSL Certificate using the NGINX IP address")
|
||||
cm := request.Post(httpsURL)
|
||||
// the default backend uses a self generated certificate
|
||||
cm.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
resp, _, errs := gorequest.New().
|
||||
Post(f.NginxHTTPSURL).
|
||||
TLSClientConfig(&tls.Config{
|
||||
// the default backend uses a self generated certificate
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
}
|
||||
resp, _, errs := cm.End()
|
||||
}).End()
|
||||
|
||||
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||
Expect(len(resp.TLS.PeerCertificates)).Should(BeNumerically("==", 1))
|
||||
|
||||
for _, pc := range resp.TLS.PeerCertificates {
|
||||
Expect(pc.Issuer.CommonName).Should(Equal("Kubernetes Ingress Controller Fake Certificate"))
|
||||
}
|
||||
|
||||
By("checking SSL Certificate using the NGINX catch all server")
|
||||
cm = request.Post(httpsURL)
|
||||
// the default backend uses a self generated certificate
|
||||
cm.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
resp, _, errs = gorequest.New().
|
||||
Post(f.NginxHTTPSURL).
|
||||
TLSClientConfig(&tls.Config{
|
||||
// the default backend uses a self generated certificate
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
}
|
||||
cm.Set("Host", "foo.bar.com")
|
||||
resp, _, errs = cm.End()
|
||||
}).
|
||||
Set("Host", "foo.bar.com").End()
|
||||
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||
Expect(len(resp.TLS.PeerCertificates)).Should(BeNumerically("==", 1))
|
||||
for _, pc := range resp.TLS.PeerCertificates {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue