77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
![]() |
/*
|
||
|
Copyright 2017 The Kubernetes Authors.
|
||
|
|
||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
you may not use this file except in compliance with the License.
|
||
|
You may obtain a copy of the License at
|
||
|
|
||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
Unless required by applicable law or agreed to in writing, software
|
||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
See the License for the specific language governing permissions and
|
||
|
limitations under the License.
|
||
|
*/
|
||
|
|
||
|
package defaultbackend
|
||
|
|
||
|
import (
|
||
|
"crypto/tls"
|
||
|
"net/http"
|
||
|
|
||
|
. "github.com/onsi/ginkgo"
|
||
|
. "github.com/onsi/gomega"
|
||
|
"github.com/parnurzeal/gorequest"
|
||
|
|
||
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||
|
)
|
||
|
|
||
|
var _ = framework.IngressNginxDescribe("Default backend - SSL", func() {
|
||
|
f := framework.NewDefaultFramework("default-backend")
|
||
|
|
||
|
BeforeEach(func() {
|
||
|
})
|
||
|
|
||
|
AfterEach(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{
|
||
|
InsecureSkipVerify: true,
|
||
|
},
|
||
|
}
|
||
|
resp, _, errs := cm.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{
|
||
|
InsecureSkipVerify: true,
|
||
|
},
|
||
|
}
|
||
|
cm.Set("Host", "foo.bar.com")
|
||
|
resp, _, errs = cm.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"))
|
||
|
}
|
||
|
})
|
||
|
})
|