Remove e2e boilerplate

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-10-29 18:39:04 -03:00
parent a06f724efa
commit 83dc4607c5
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
44 changed files with 432 additions and 871 deletions

View file

@ -33,28 +33,22 @@ var _ = framework.IngressNginxDescribe("Global access block", func() {
host := "global-access-block"
BeforeEach(func() {
err := f.NewEchoDeploymentWithReplicas(1)
Expect(err).NotTo(HaveOccurred())
ing, err := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil))
Expect(err).NotTo(HaveOccurred())
Expect(ing).NotTo(BeNil())
f.NewEchoDeploymentWithReplicas(1)
f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, nil))
})
AfterEach(func() {
})
It("should block CIDRs defined in the ConfigMap", func() {
err := f.UpdateNginxConfigMapData("block-cidrs", "172.16.0.0/12,192.168.0.0/16,10.0.0.0/8")
Expect(err).NotTo(HaveOccurred())
f.UpdateNginxConfigMapData("block-cidrs", "172.16.0.0/12,192.168.0.0/16,10.0.0.0/8")
err = f.WaitForNginxConfiguration(
f.WaitForNginxConfiguration(
func(cfg string) bool {
return strings.Contains(cfg, "deny 172.16.0.0/12;") &&
strings.Contains(cfg, "deny 192.168.0.0/16;") &&
strings.Contains(cfg, "deny 10.0.0.0/8;")
})
Expect(err).NotTo(HaveOccurred())
// This test works for minikube, but may have problems with real kubernetes clusters,
// especially if connection is done via Internet. In this case, the test should be disabled/removed.
@ -67,15 +61,13 @@ var _ = framework.IngressNginxDescribe("Global access block", func() {
})
It("should block User-Agents defined in the ConfigMap", func() {
err := f.UpdateNginxConfigMapData("block-user-agents", "~*chrome\\/68\\.0\\.3440\\.106\\ safari\\/537\\.36,AlphaBot")
Expect(err).NotTo(HaveOccurred())
f.UpdateNginxConfigMapData("block-user-agents", "~*chrome\\/68\\.0\\.3440\\.106\\ safari\\/537\\.36,AlphaBot")
err = f.WaitForNginxConfiguration(
f.WaitForNginxConfiguration(
func(cfg string) bool {
return strings.Contains(cfg, "~*chrome\\/68\\.0\\.3440\\.106\\ safari\\/537\\.36 1;") &&
strings.Contains(cfg, "AlphaBot 1;")
})
Expect(err).NotTo(HaveOccurred())
// Should be blocked
resp, _, errs := gorequest.New().
@ -105,15 +97,13 @@ var _ = framework.IngressNginxDescribe("Global access block", func() {
})
It("should block Referers defined in the ConfigMap", func() {
err := f.UpdateNginxConfigMapData("block-referers", "~*example\\.com,qwerty")
Expect(err).NotTo(HaveOccurred())
f.UpdateNginxConfigMapData("block-referers", "~*example\\.com,qwerty")
err = f.WaitForNginxConfiguration(
f.WaitForNginxConfiguration(
func(cfg string) bool {
return strings.Contains(cfg, "~*example\\.com 1;") &&
strings.Contains(cfg, "qwerty 1;")
})
Expect(err).NotTo(HaveOccurred())
// Should be blocked
resp, _, errs := gorequest.New().