diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index ed51d539c..f68c7bc07 100644 --- a/test/e2e/annotations/auth.go +++ b/test/e2e/annotations/auth.go @@ -314,15 +314,39 @@ var _ = framework.DescribeAnnotation("auth-*", func() { }) ginkgo.It("retains cookie set by external authentication server", func() { - ginkgo.Skip("Skipping test until refactoring") - // TODO: this test should look like https://gist.github.com/aledbf/250645d76c080677c695929273f8fd22 + host := "auth-check-cookies" - host := "auth" + cfg := `# +events { + worker_connections 1024; + multi_accept on; +} - f.NewHttpbinDeployment() +http { + default_type 'text/plain'; + client_max_body_size 0; - err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, framework.HTTPBinService, f.Namespace, 1) - assert.Nil(ginkgo.GinkgoT(), err) + server { + access_log on; + access_log /dev/stdout; + + listen 80; + + location ~ ^/cookies/set/(?.*)/(?.*) { + content_by_lua_block { + ngx.header['Set-Cookie'] = {ngx.var.key.."="..ngx.var.value} + ngx.say("OK") + } + } + + location / { + return 200; + } + } +} +` + + f.NGINXWithConfigDeployment(framework.HTTPBinService, cfg) e, err := f.KubeClientSet.CoreV1().Endpoints(f.Namespace).Get(context.TODO(), framework.HTTPBinService, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index e93c91247..14ce217c0 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -88,9 +88,7 @@ func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas i // NewSlowEchoDeployment creates a new deployment of the slow echo server image in a particular namespace. func (f *Framework) NewSlowEchoDeployment() { - data := map[string]string{} - data["nginx.conf"] = `# - + cfg := `# events { worker_connections 1024; multi_accept on; @@ -123,20 +121,29 @@ http { ` + f.NGINXWithConfigDeployment(SlowEchoService, cfg) +} + +// NGINXWithConfigDeployment creates an NGINX deployment using a configmap containing the nginx.conf configuration +func (f *Framework) NGINXWithConfigDeployment(name string, cfg string) { + cfgMap := map[string]string{ + "nginx.conf": cfg, + } + _, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(context.TODO(), &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: SlowEchoService, + Name: name, Namespace: f.Namespace, }, - Data: data, + Data: cfgMap, }, metav1.CreateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "creating configmap") - deployment := newDeployment(SlowEchoService, f.Namespace, "k8s.gcr.io/ingress-nginx/nginx:v20201028-g2c1279cd8@sha256:bd22e4f9bbf88aee527a86692be4442d03fa1ef2df94356312c9db8bec1f7ea3", 80, 1, + deployment := newDeployment(name, f.Namespace, "k8s.gcr.io/ingress-nginx/nginx:v20201028-g2c1279cd8@sha256:bd22e4f9bbf88aee527a86692be4442d03fa1ef2df94356312c9db8bec1f7ea3", 80, 1, nil, []corev1.VolumeMount{ { - Name: SlowEchoService, + Name: name, MountPath: "/etc/nginx/nginx.conf", SubPath: "nginx.conf", ReadOnly: true, @@ -144,11 +151,11 @@ http { }, []corev1.Volume{ { - Name: SlowEchoService, + Name: name, VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ - Name: SlowEchoService, + Name: name, }, }, }, @@ -160,7 +167,7 @@ http { service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: SlowEchoService, + Name: name, Namespace: f.Namespace, }, Spec: corev1.ServiceSpec{ @@ -173,14 +180,14 @@ http { }, }, Selector: map[string]string{ - "app": SlowEchoService, + "app": name, }, }, } f.EnsureService(service) - err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, SlowEchoService, f.Namespace, 1) + err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, 1) assert.Nil(ginkgo.GinkgoT(), err, "waiting for endpoints to become ready") }