Refactor e2e tests to use testify y httpexpect

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-19 00:08:56 -03:00
parent 046e2d959d
commit f9624cbe46
80 changed files with 2280 additions and 2631 deletions

View file

@ -18,15 +18,15 @@ package lua
import (
"fmt"
"net/http"
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
networking "k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -37,15 +37,15 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
f := framework.NewDefaultFramework("dynamic-certificate")
host := "foo.com"
BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(1)
ginkgo.BeforeEach(func() {
f.NewEchoDeployment()
})
It("picks up the certificate when we add TLS spec to existing ingress", func() {
ginkgo.It("picks up the certificate when we add TLS spec to existing ingress", func() {
ensureIngress(f, host, framework.EchoService)
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ing.Spec.TLS = []networking.IngressTLS{
{
Hosts: []string{host},
@ -56,15 +56,17 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
ing.Spec.TLS[0].Hosts,
ing.Spec.TLS[0].SecretName,
ing.Namespace)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
_, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(ing)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host)
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, host)
})
It("picks up the previously missing secret for a given ingress without reloading", func() {
ginkgo.It("picks up the previously missing secret for a given ingress without reloading", func() {
ing := framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil)
f.EnsureIngress(ing)
@ -72,56 +74,57 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
ip := f.GetNginxPodIP()
mf, err := f.GetMetric("nginx_ingress_controller_success", ip[0])
Expect(err).ToNot(HaveOccurred())
Expect(mf).ToNot(BeNil())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotNil(ginkgo.GinkgoT(), mf)
rc0, err := extractReloadCount(mf)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, "ingress.local")
ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, "ingress.local")
_, err = framework.CreateIngressTLSSecret(f.KubeClientSet,
ing.Spec.TLS[0].Hosts,
ing.Spec.TLS[0].SecretName,
ing.Namespace)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host)
ginkgo.By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, host)
log, err := f.NginxLogs()
Expect(err).ToNot(HaveOccurred())
Expect(log).ToNot(BeEmpty())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotEmpty(ginkgo.GinkgoT(), log)
By("skipping Nginx reload")
ginkgo.By("skipping Nginx reload")
mf, err = f.GetMetric("nginx_ingress_controller_success", ip[0])
Expect(err).ToNot(HaveOccurred())
Expect(mf).ToNot(BeNil())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotNil(ginkgo.GinkgoT(), mf)
rc1, err := extractReloadCount(mf)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
Expect(rc0).To(BeEquivalentTo(rc1))
assert.Equal(ginkgo.GinkgoT(), rc0, rc1)
})
Context("given an ingress with TLS correctly configured", func() {
BeforeEach(func() {
ginkgo.Context("given an ingress with TLS correctly configured", func() {
ginkgo.BeforeEach(func() {
ing := f.EnsureIngress(framework.NewSingleIngressWithTLS(host, "/", host, []string{host}, f.Namespace, framework.EchoService, 80, nil))
time.Sleep(waitForLuaSync)
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, "ingress.local")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, "ingress.local")
_, err := framework.CreateIngressTLSSecret(f.KubeClientSet,
ing.Spec.TLS[0].Hosts,
ing.Spec.TLS[0].SecretName,
ing.Namespace)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
By("configuring certificate_by_lua and skipping Nginx configuration of the new certificate")
ginkgo.By("configuring certificate_by_lua and skipping Nginx configuration of the new certificate")
f.WaitForNginxServer(ing.Spec.TLS[0].Hosts[0],
func(server string) bool {
return strings.Contains(server, "listen 443")
@ -129,8 +132,8 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
time.Sleep(waitForLuaSync)
By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host)
ginkgo.By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, host)
})
/*
@ -138,98 +141,109 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() {
because Go transport code strips (https://github.com/golang/go/blob/431b5c69ca214ce4291f008c1ce2a50b22bc2d2d/src/crypto/tls/handshake_messages.go#L424)
trailing dot from SNI as suggest by the standard (https://tools.ietf.org/html/rfc6066#section-3).
*/
It("supports requests with domain with trailing dot", func() {
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host+".", host)
ginkgo.It("supports requests with domain with trailing dot", func() {
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host+".", host)
})
It("picks up the updated certificate without reloading", func() {
ginkgo.It("picks up the updated certificate without reloading", func() {
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host)
ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host)
_, err = framework.CreateIngressTLSSecret(f.KubeClientSet,
ing.Spec.TLS[0].Hosts,
ing.Spec.TLS[0].SecretName,
ing.Namespace)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
By("configuring certificate_by_lua and skipping Nginx configuration of the new certificate")
ginkgo.By("configuring certificate_by_lua and skipping Nginx configuration of the new certificate")
f.WaitForNginxServer(ing.Spec.TLS[0].Hosts[0],
func(server string) bool {
return strings.Contains(server, "listen 443")
})
By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, host)
ginkgo.By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, host)
log, err := f.NginxLogs()
Expect(err).ToNot(HaveOccurred())
Expect(log).ToNot(BeEmpty())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotEmpty(ginkgo.GinkgoT(), log)
index := strings.Index(log, "id=dummy_log_splitter_foo_bar")
assert.GreaterOrEqual(ginkgo.GinkgoT(), index, 0, "log does not contains id=dummy_log_splitter_foo_bar")
restOfLogs := log[index:]
By("skipping Nginx reload")
Expect(restOfLogs).ToNot(ContainSubstring(logRequireBackendReload))
Expect(restOfLogs).ToNot(ContainSubstring(logBackendReloadSuccess))
ginkgo.By("skipping Nginx reload")
assert.NotContains(ginkgo.GinkgoT(), restOfLogs, logRequireBackendReload)
assert.NotContains(ginkgo.GinkgoT(), restOfLogs, logBackendReloadSuccess)
})
It("falls back to using default certificate when secret gets deleted without reloading", func() {
ginkgo.It("falls back to using default certificate when secret gets deleted without reloading", func() {
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host)
ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host)
ip := f.GetNginxPodIP()
mf, err := f.GetMetric("nginx_ingress_controller_success", ip[0])
Expect(err).ToNot(HaveOccurred())
Expect(mf).ToNot(BeNil())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotNil(ginkgo.GinkgoT(), mf)
rc0, err := extractReloadCount(mf)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
err = f.KubeClientSet.CoreV1().Secrets(ing.Namespace).Delete(ing.Spec.TLS[0].SecretName, nil)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync * 2)
time.Sleep(waitForLuaSync)
By("serving the default certificate on HTTPS endpoint")
ensureHTTPSRequest(f.GetURL(framework.HTTPS), host, "ingress.local")
ginkgo.By("serving the default certificate on HTTPS endpoint")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), host, "ingress.local")
mf, err = f.GetMetric("nginx_ingress_controller_success", ip[0])
Expect(err).ToNot(HaveOccurred())
Expect(mf).ToNot(BeNil())
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotNil(ginkgo.GinkgoT(), mf)
rc1, err := extractReloadCount(mf)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
By("skipping Nginx reload")
Expect(rc0).To(BeEquivalentTo(rc1))
ginkgo.By("skipping Nginx reload")
assert.Equal(ginkgo.GinkgoT(), rc0, rc1)
})
It("picks up a non-certificate only change", func() {
ginkgo.It("picks up a non-certificate only change", func() {
newHost := "foo2.com"
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ing.Spec.Rules[0].Host = newHost
_, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(ing)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f.GetURL(framework.HTTPS), newHost, "ingress.local")
ginkgo.By("serving the configured certificate on HTTPS endpoint")
ensureHTTPSRequest(f, f.GetURL(framework.HTTPS), newHost, "ingress.local")
})
It("removes HTTPS configuration when we delete TLS spec", func() {
ginkgo.It("removes HTTPS configuration when we delete TLS spec", func() {
ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ing.Spec.TLS = []networking.IngressTLS{}
_, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(ing)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
time.Sleep(waitForLuaSync)
ensureRequest(f, host)
f.HTTPTestClient().
GET("/").
WithHeader("Host", host).
Expect().
Status(http.StatusOK)
})
})
})

View file

@ -23,10 +23,8 @@ import (
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/parnurzeal/gorequest"
"github.com/onsi/ginkgo"
"github.com/stretchr/testify/assert"
networking "k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -40,18 +38,19 @@ const (
logRequireBackendReload = "Configuration changes detected, backend reload required"
logBackendReloadSuccess = "Backend successfully reloaded"
logInitialConfigSync = "Initial synchronization of the NGINX configuration"
waitForLuaSync = 5 * time.Second
waitForLuaSync = 5 * time.Second
)
var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
f := framework.NewDefaultFramework("dynamic-configuration")
BeforeEach(func() {
ginkgo.BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(1)
ensureIngress(f, "foo.com", framework.EchoService)
})
It("configures balancer Lua middleware correctly", func() {
ginkgo.It("configures balancer Lua middleware correctly", func() {
f.WaitForNginxConfiguration(func(cfg string) bool {
return strings.Contains(cfg, "balancer.init_worker()") && strings.Contains(cfg, "balancer.balance()")
})
@ -62,8 +61,8 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
})
})
Context("when only backends change", func() {
It("handles endpoints only changes", func() {
ginkgo.Context("when only backends change", func() {
ginkgo.It("handles endpoints only changes", func() {
var nginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
nginxConfig = cfg
@ -72,19 +71,23 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
replicas := 2
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, replicas, nil)
Expect(err).NotTo(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ensureRequest(f, "foo.com")
f.HTTPTestClient().
GET("/").
WithHeader("Host", "foo.com").
Expect().
Status(http.StatusOK)
var newNginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
newNginxConfig = cfg
return true
})
Expect(nginxConfig).Should(Equal(newNginxConfig))
assert.Equal(ginkgo.GinkgoT(), nginxConfig, newNginxConfig)
})
It("handles endpoints only changes (down scaling of replicas)", func() {
ginkgo.It("handles endpoints only changes (down scaling of replicas)", func() {
var nginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
nginxConfig = cfg
@ -93,52 +96,79 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
replicas := 2
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, replicas, nil)
Expect(err).NotTo(HaveOccurred())
time.Sleep(waitForLuaSync * 2)
assert.Nil(ginkgo.GinkgoT(), err)
ensureRequest(f, "foo.com")
time.Sleep(waitForLuaSync)
f.HTTPTestClient().
GET("/").
WithHeader("Host", "foo.com").
Expect().
Status(http.StatusOK)
var newNginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
newNginxConfig = cfg
return true
})
Expect(nginxConfig).Should(Equal(newNginxConfig))
assert.Equal(ginkgo.GinkgoT(), nginxConfig, newNginxConfig)
err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, framework.EchoService, 0, nil)
assert.Nil(ginkgo.GinkgoT(), err)
Expect(err).NotTo(HaveOccurred())
time.Sleep(waitForLuaSync * 2)
time.Sleep(waitForLuaSync)
ensureRequestWithStatus(f, "foo.com", 503)
f.HTTPTestClient().
GET("/").
WithHeader("Host", "foo.com").
Expect().
Status(503)
})
It("handles endpoints only changes consistently (down scaling of replicas vs. empty service)", func() {
ginkgo.It("handles endpoints only changes consistently (down scaling of replicas vs. empty service)", func() {
deploymentName := "scalingecho"
f.NewEchoDeploymentWithNameAndReplicas(deploymentName, 0)
createIngress(f, "scaling.foo.com", deploymentName)
originalResponseCode := runRequest(f, "scaling.foo.com")
resp := f.HTTPTestClient().
GET("/").
WithHeader("Host", "scaling.foo.com").
Expect().Raw()
originalResponseCode := resp.StatusCode
replicas := 2
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, deploymentName, replicas, nil)
Expect(err).NotTo(HaveOccurred())
time.Sleep(waitForLuaSync * 2)
assert.Nil(ginkgo.GinkgoT(), err)
expectedSuccessResponseCode := runRequest(f, "scaling.foo.com")
time.Sleep(waitForLuaSync)
resp = f.HTTPTestClient().
GET("/").
WithHeader("Host", "scaling.foo.com").
Expect().Raw()
expectedSuccessResponseCode := resp.StatusCode
replicas = 0
err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, deploymentName, replicas, nil)
Expect(err).NotTo(HaveOccurred())
time.Sleep(waitForLuaSync * 2)
assert.Nil(ginkgo.GinkgoT(), err)
expectedFailureResponseCode := runRequest(f, "scaling.foo.com")
time.Sleep(waitForLuaSync)
Expect(originalResponseCode).To(Equal(503), "Expected empty service to return 503 response.")
Expect(expectedFailureResponseCode).To(Equal(503), "Expected downscaled replicaset to return 503 response.")
Expect(expectedSuccessResponseCode).To(Equal(200), "Expected intermediate scaled replicaset to return a 200 response.")
resp = f.HTTPTestClient().
GET("/").
WithHeader("Host", "scaling.foo.com").
Expect().Raw()
expectedFailureResponseCode := resp.StatusCode
assert.Equal(ginkgo.GinkgoT(), originalResponseCode, 503, "Expected empty service to return 503 response.")
assert.Equal(ginkgo.GinkgoT(), expectedFailureResponseCode, 503, "Expected downscaled replicaset to return 503 response.")
assert.Equal(ginkgo.GinkgoT(), expectedSuccessResponseCode, 200, "Expected intermediate scaled replicaset to return a 200 response.")
})
It("handles an annotation change", func() {
ginkgo.It("handles an annotation change", func() {
var nginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
nginxConfig = cfg
@ -146,13 +176,17 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
})
ingress, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get("foo.com", metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ingress.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/load-balance"] = "round_robin"
_, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(ingress)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
ensureRequest(f, "foo.com")
f.HTTPTestClient().
GET("/").
WithHeader("Host", "foo.com").
Expect().
Status(http.StatusOK)
var newNginxConfig string
f.WaitForNginxConfiguration(func(cfg string) bool {
@ -160,31 +194,35 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() {
return true
})
Expect(nginxConfig).Should(Equal(newNginxConfig))
assert.Equal(ginkgo.GinkgoT(), nginxConfig, newNginxConfig)
})
})
It("sets controllerPodsCount in Lua general configuration", func() {
ginkgo.It("sets controllerPodsCount in Lua general configuration", func() {
// https://github.com/curl/curl/issues/936
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/general", nginx.StatusPort)
output, err := f.ExecIngressPod(curlCmd)
Expect(err).ToNot(HaveOccurred())
Expect(output).Should(Equal(`{"controllerPodsCount":1}`))
assert.Nil(ginkgo.GinkgoT(), err)
assert.Equal(ginkgo.GinkgoT(), output, `{"controllerPodsCount":1}`)
err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 3, nil)
Expect(err).ToNot(HaveOccurred())
assert.Nil(ginkgo.GinkgoT(), err)
output, err = f.ExecIngressPod(curlCmd)
Expect(err).ToNot(HaveOccurred())
Expect(output).Should(Equal(`{"controllerPodsCount":3}`))
assert.Nil(ginkgo.GinkgoT(), err)
assert.Equal(ginkgo.GinkgoT(), output, `{"controllerPodsCount":3}`)
})
})
func ensureIngress(f *framework.Framework, host string, deploymentName string) *networking.Ingress {
ing := createIngress(f, host, deploymentName)
ensureRequest(f, host)
f.HTTPTestClient().
GET("/").
WithHeader("Host", host).
Expect().
Status(http.StatusOK)
return ing
}
@ -205,44 +243,18 @@ func createIngress(f *framework.Framework, host string, deploymentName string) *
return ing
}
func ensureRequest(f *framework.Framework, host string) {
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
}
func ensureHTTPSRequest(f *framework.Framework, url string, host string, expectedDNSName string) {
resp := f.HTTPTestClientWithTLSConfig(&tls.Config{
ServerName: host,
InsecureSkipVerify: true,
}).
GET("/").
WithURL(url).
WithHeader("Host", host).
Expect().
Raw()
func ensureRequestWithStatus(f *framework.Framework, host string, statusCode int) {
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(statusCode))
}
func runRequest(f *framework.Framework, host string) int {
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()
Expect(errs).Should(BeEmpty())
return resp.StatusCode
}
func ensureHTTPSRequest(url string, host string, expectedDNSName string) {
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
TLSClientConfig(&tls.Config{
InsecureSkipVerify: true,
ServerName: host,
}).
End()
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(len(resp.TLS.PeerCertificates)).Should(BeNumerically("==", 1))
Expect(resp.TLS.PeerCertificates[0].DNSNames[0]).Should(Equal(expectedDNSName))
assert.Equal(ginkgo.GinkgoT(), resp.StatusCode, http.StatusOK)
assert.Equal(ginkgo.GinkgoT(), len(resp.TLS.PeerCertificates), 1)
assert.Equal(ginkgo.GinkgoT(), resp.TLS.PeerCertificates[0].DNSNames[0], expectedDNSName)
}