Skip to content

Commit c2e842e

Browse files
committed
added ginkgo test to verify dex volume and volumeMounts
Signed-off-by: Alka Kumari <[email protected]>
1 parent 9e522bf commit c2e842e

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/openshift/e2e/ginkgo/parallel/1-007_validate_volume_mounts_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,76 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
143143

144144
})
145145

146+
It("verifies that dex controller has the expected volumes and volumemounts, including custom volumes and volumemounts", func() {
147+
148+
By("creating new namespace-scoped Argo CD instance with dex enabled and custom volumes and volume mounts")
149+
randomNS, cleanupFunc = fixture.CreateRandomE2ETestNamespaceWithCleanupFunc()
150+
151+
By("creating ConfigMap for custom dex configuration")
152+
dexConfigMap := &corev1.ConfigMap{
153+
ObjectMeta: metav1.ObjectMeta{Name: "dex-custom-config", Namespace: randomNS.Name},
154+
Data: map[string]string{
155+
"config.yaml": "# Custom dex configuration for testing volumes",
156+
},
157+
}
158+
Expect(k8sClient.Create(ctx, dexConfigMap)).To(Succeed())
159+
160+
argoCDRandomNS := &argov1beta1api.ArgoCD{
161+
ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: randomNS.Name},
162+
Spec: argov1beta1api.ArgoCDSpec{
163+
SSO: &argov1beta1api.ArgoCDSSOSpec{
164+
Provider: argov1beta1api.SSOProviderTypeDex,
165+
Dex: &argov1beta1api.ArgoCDDexSpec{
166+
OpenShiftOAuth: true,
167+
Volumes: []corev1.Volume{
168+
{Name: "custom-dex-volume", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
169+
},
170+
VolumeMounts: []corev1.VolumeMount{
171+
{Name: "custom-dex-volume", MountPath: "/custom/dex"},
172+
},
173+
},
174+
},
175+
},
176+
}
177+
Expect(k8sClient.Create(ctx, argoCDRandomNS)).To(Succeed())
178+
179+
By("verifying Argo CD is available and Dex is running")
180+
Eventually(argoCDRandomNS, "5m", "5s").Should(argocdFixture.BeAvailable())
181+
182+
By("verifying dex server Deployment has the expected volume and volumemount values")
183+
dexServerDepl := appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-dex-server", Namespace: randomNS.Name}}
184+
185+
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(&dexServerDepl), &dexServerDepl)).To(Succeed())
186+
187+
// Check that custom volume mounts are present
188+
Expect(dexServerDepl.Spec.Template.Spec.Containers[0].VolumeMounts).To(Equal([]corev1.VolumeMount{
189+
{Name: "static-files", MountPath: "/shared"},
190+
{Name: "dexconfig", MountPath: "/tmp"},
191+
{Name: "custom-dex-volume", MountPath: "/custom/dex"},
192+
}))
193+
194+
// Verify that the deployment has the expected volumes (including custom ones)
195+
Expect(dexServerDepl.Spec.Template.Spec.Volumes).To(Equal([]corev1.Volume{
196+
{
197+
Name: "static-files",
198+
VolumeSource: corev1.VolumeSource{
199+
EmptyDir: &corev1.EmptyDirVolumeSource{},
200+
},
201+
},
202+
{
203+
Name: "dexconfig",
204+
VolumeSource: corev1.VolumeSource{
205+
EmptyDir: &corev1.EmptyDirVolumeSource{},
206+
},
207+
},
208+
{
209+
Name: "custom-dex-volume",
210+
VolumeSource: corev1.VolumeSource{
211+
EmptyDir: &corev1.EmptyDirVolumeSource{},
212+
},
213+
},
214+
}))
215+
})
216+
146217
})
147218
})

0 commit comments

Comments
 (0)