Remove e2e boilerplate
This commit is contained in:
parent
a06f724efa
commit
83dc4607c5
44 changed files with 432 additions and 871 deletions
|
|
@ -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().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue