Skip to content

Commit

Permalink
chore: remove echo from snippet tests (#10110)
Browse files Browse the repository at this point in the history
Signed-off-by: Spazzy <[email protected]>
  • Loading branch information
Spazzy757 authored Jun 23, 2023
1 parent 08158df commit f8bf5a3
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions test/e2e/annotations/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@ import (
)

var _ = framework.DescribeAnnotation("configuration-snippet", func() {
f := framework.NewDefaultFramework("configurationsnippet")
f := framework.NewDefaultFramework(
"configurationsnippet",
framework.WithHTTPBunEnabled(),
)

ginkgo.BeforeEach(func() {
f.NewEchoDeployment()
})

ginkgo.It(`set snippet "more_set_headers "Foo1: Bar1";" in all locations"`, func() {
ginkgo.It("set snippet more_set_headers in all locations", func() {
host := "configurationsnippet.foo.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/configuration-snippet": `
more_set_headers "Foo1: Bar1";`,
"nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Foo1: Bar1";`,
}

ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing)
f.EnsureIngress(framework.NewSingleIngress(
host,
"/",
host,
f.Namespace,
framework.HTTPBunService,
80,
annotations))

f.WaitForNginxServer(host,
func(server string) bool {
Expand All @@ -51,23 +55,32 @@ var _ = framework.DescribeAnnotation("configuration-snippet", func() {
GET("/").
WithHeader("Host", host).
Expect().
Status(http.StatusOK).Headers().
Status(http.StatusOK).
Headers().
ValueEqual("Foo1", []string{"Bar1"})
})

ginkgo.It(`drops snippet "more_set_headers "Foo1: Bar1";" in all locations if disabled by admin"`, func() {
ginkgo.It("drops snippet more_set_header in all locations if disabled by admin", func() {
host := "noconfigurationsnippet.foo.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/configuration-snippet": `
more_set_headers "Foo1: Bar1";`,
"nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Foo1: Bar1";`,
}

ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
ing := framework.NewSingleIngress(
host,
"/",
host,
f.Namespace,
framework.HTTPBunService,
80,
annotations)

f.UpdateNginxConfigMapData("allow-snippet-annotations", "false")
defer func() {
// Return to the original value
f.UpdateNginxConfigMapData("allow-snippet-annotations", "true")
}()

// Sleep a while just to guarantee that the configmap is applied
framework.Sleep()
f.EnsureIngress(ing)
Expand All @@ -81,7 +94,8 @@ var _ = framework.DescribeAnnotation("configuration-snippet", func() {
GET("/").
WithHeader("Host", host).
Expect().
Status(http.StatusOK).Headers().
Status(http.StatusOK).
Headers().
NotContainsKey("Foo1")
})
})

0 comments on commit f8bf5a3

Please sign in to comment.