Refactor e2e tests to use the service ClusterIP

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-02-22 11:03:42 -03:00
parent f04361cc06
commit 5e249d3366
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
80 changed files with 777 additions and 706 deletions

View file

@ -40,7 +40,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
host := "foo"
createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "active"})
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -55,7 +55,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
"nginx.ingress.kubernetes.io/lua-resty-waf": "active",
"nginx.ingress.kubernetes.io/lua-resty-waf-ignore-rulesets": "41000_sqli, 42000_xss"})
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -70,7 +70,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
"nginx.ingress.kubernetes.io/lua-resty-waf": "active",
"nginx.ingress.kubernetes.io/lua-resty-waf-score-threshold": "20"})
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -86,7 +86,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
"nginx.ingress.kubernetes.io/lua-resty-waf-allow-unknown-content-types": "true",
"nginx.ingress.kubernetes.io/lua-resty-waf": "active"})
url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -103,7 +103,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
"nginx.ingress.kubernetes.io/lua-resty-waf-process-multipart-body": "false",
"nginx.ingress.kubernetes.io/lua-resty-waf": "active"})
url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -119,7 +119,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
createIngress(f, host, "http-svc", 80, map[string]string{
"nginx.ingress.kubernetes.io/lua-resty-waf": "active"})
url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -148,7 +148,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
]=]`,
})
url := fmt.Sprintf("%s?msg=my-message", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=my-message", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -157,7 +157,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
Expect(len(errs)).Should(Equal(0))
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
url = fmt.Sprintf("%s?msg=my-foo-message", f.IngressController.HTTPURL)
url = fmt.Sprintf("%s?msg=my-foo-message", f.GetURL(framework.HTTP))
resp, _, errs = gorequest.New().
Get(url).
Set("Host", host).
@ -172,7 +172,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
host := "foo"
createIngress(f, host, "http-svc", 80, map[string]string{})
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -185,7 +185,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
host := "foo"
createIngress(f, host, "http-svc", 80, map[string]string{"nginx.ingress.kubernetes.io/lua-resty-waf": "simulate"})
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.IngressController.HTTPURL)
url := fmt.Sprintf("%s?msg=<A href=\"http://mysite.com/\">XSS</A>", f.GetURL(framework.HTTP))
resp, _, errs := gorequest.New().
Get(url).
Set("Host", host).
@ -203,7 +203,7 @@ var _ = framework.IngressNginxDescribe("Annotations - lua-resty-waf", func() {
})
func createIngress(f *framework.Framework, host, service string, port int, annotations map[string]string) {
ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, service, port, &annotations)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, service, port, &annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
@ -214,7 +214,7 @@ func createIngress(f *framework.Framework, host, service string, port int, annot
time.Sleep(1 * time.Second)
resp, body, errs := gorequest.New().
Get(f.IngressController.HTTPURL).
Get(f.GetURL(framework.HTTP)).
Set("Host", host).
End()