Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove echo from snippet tests #10110

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
})
})