Skip to content

Commit

Permalink
Enable external auth e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Nov 13, 2020
1 parent 8b99f49 commit 8a21868
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
36 changes: 30 additions & 6 deletions test/e2e/annotations/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/(?<key>.*)/(?<value>.*) {
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)
Expand Down
31 changes: 19 additions & 12 deletions test/e2e/framework/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -123,32 +121,41 @@ 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,
},
},
[]corev1.Volume{
{
Name: SlowEchoService,
Name: name,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: SlowEchoService,
Name: name,
},
},
},
Expand All @@ -160,7 +167,7 @@ http {

service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: SlowEchoService,
Name: name,
Namespace: f.Namespace,
},
Spec: corev1.ServiceSpec{
Expand All @@ -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")
}

Expand Down

0 comments on commit 8a21868

Please sign in to comment.