Commit 00088a20 authored by André Carvalho's avatar André Carvalho

adds test for tls certificate

parent b9382a66
......@@ -179,6 +179,51 @@ func Test_NewDeployment(t *testing.T) {
return d
},
},
{
name: "with-tls",
nginxFn: func(n v1alpha1.Nginx) v1alpha1.Nginx {
n.Spec.TLSSecret = &v1alpha1.TLSSecret{
SecretName: "my-secret",
KeyField: "key-field",
KeyPath: "key-path",
CertificateField: "cert-field",
CertificatePath: "cert-path",
}
return n
},
deployFn: func(d appv1.Deployment) appv1.Deployment {
d.Spec.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{
{
Name: "http",
ContainerPort: int32(80),
Protocol: corev1.ProtocolTCP,
},
{
Name: "https",
ContainerPort: int32(443),
Protocol: corev1.ProtocolTCP,
},
}
d.Spec.Template.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{
{Name: "nginx-certs", MountPath: "/etc/nginx/certs"},
}
d.Spec.Template.Spec.Volumes = []corev1.Volume{
{
Name: "nginx-certs",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: "my-secret",
Items: []corev1.KeyToPath{
{Key: "key-field", Path: "key-path"},
{Key: "cert-field", Path: "cert-path"},
},
},
},
},
}
return d
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment