Enable external auth e2e tests
This commit is contained in:
parent
8b99f49d2d
commit
8a218687e3
2 changed files with 49 additions and 18 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue