Skip to content

Commit 421cfa5

Browse files
trdoyle81Triona Doyle
andauthored
Port 1-068_validate_redis_secure_comm_autotls_no_ha to Ginkgo (#1039)
Signed-off-by: Triona Doyle <bot@example.com> Co-authored-by: Triona Doyle <bot@example.com>
1 parent 3c49188 commit 421cfa5

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package parallel
2+
3+
import (
4+
"context"
5+
6+
argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"
7+
. "github.com/onsi/ginkgo/v2"
8+
. "github.com/onsi/gomega"
9+
"github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture"
10+
argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd"
11+
deplFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/deployment"
12+
k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s"
13+
statefulsetFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/statefulset"
14+
fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"
15+
appsv1 "k8s.io/api/apps/v1"
16+
corev1 "k8s.io/api/core/v1"
17+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18+
"sigs.k8s.io/controller-runtime/pkg/client"
19+
)
20+
21+
var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
22+
23+
Context("1-068_validate_redis_secure_comm_autotls_no_ha", func() {
24+
25+
var (
26+
k8sClient client.Client
27+
ctx context.Context
28+
ns *corev1.Namespace
29+
cleanupFunc func()
30+
)
31+
32+
BeforeEach(func() {
33+
fixture.EnsureParallelCleanSlate()
34+
k8sClient, _ = fixtureUtils.GetE2ETestKubeClient()
35+
ctx = context.Background()
36+
})
37+
38+
AfterEach(func() {
39+
defer cleanupFunc()
40+
fixture.OutputDebugOnFail(ns)
41+
})
42+
43+
It("validates that the operator configures Redis using auto-gen TLS certificates when HA is disabled", func() {
44+
45+
expectComponentsAreRunning := func() {
46+
deploymentsShouldExist := []string{"argocd-redis", "argocd-server", "argocd-repo-server"}
47+
for _, deplName := range deploymentsShouldExist {
48+
depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: deplName, Namespace: ns.Name}}
49+
Eventually(depl).Should(k8sFixture.ExistByName())
50+
Eventually(depl).Should(deplFixture.HaveReadyReplicas(1))
51+
}
52+
53+
statefulSet := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{Name: "argocd-application-controller", Namespace: ns.Name}}
54+
Eventually(statefulSet).Should(k8sFixture.ExistByName())
55+
Eventually(statefulSet).Should(statefulsetFixture.HaveReadyReplicas(1))
56+
}
57+
58+
By("creating a namespace-scoped Argo CD instance with HA disabled")
59+
ns, cleanupFunc = fixture.CreateRandomE2ETestNamespaceWithCleanupFunc()
60+
61+
argoCD := &argov1beta1api.ArgoCD{
62+
ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: ns.Name},
63+
Spec: argov1beta1api.ArgoCDSpec{
64+
HA: argov1beta1api.ArgoCDHASpec{
65+
Enabled: false,
66+
},
67+
Redis: argov1beta1api.ArgoCDRedisSpec{},
68+
},
69+
}
70+
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
71+
72+
By("waiting for the non-HA instance to become available")
73+
Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable())
74+
expectComponentsAreRunning()
75+
76+
By("enabling Redis AutoTLS for OpenShift on the instance")
77+
argocdFixture.Update(argoCD, func(ac *argov1beta1api.ArgoCD) {
78+
ac.Spec.Redis.AutoTLS = "openshift"
79+
})
80+
81+
By("waiting for the components to reconcile and restart")
82+
expectComponentsAreRunning()
83+
84+
By("verifying the Redis TLS secret exists and contains the correct data")
85+
redisTLSSecret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argocd-operator-redis-tls", Namespace: ns.Name}}
86+
Eventually(redisTLSSecret).Should(k8sFixture.ExistByName())
87+
88+
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(redisTLSSecret), redisTLSSecret)).To(Succeed())
89+
Expect(redisTLSSecret.Type).To(Equal(corev1.SecretTypeTLS), "Secret type should be kubernetes.io/tls")
90+
Expect(len(redisTLSSecret.Data)).To(Equal(2), "Secret should contain exactly 2 data items (tls.key and tls.crt)")
91+
92+
By("verifying the redis-server deployment has the expected TLS flags")
93+
redisDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-redis", Namespace: ns.Name}}
94+
95+
redisTlsFlags := []string{
96+
"--tls-port 6379",
97+
"--port 0",
98+
"--tls-cert-file /app/config/redis/tls/tls.crt",
99+
"--tls-key-file /app/config/redis/tls/tls.key",
100+
"--tls-auth-clients no",
101+
}
102+
for _, flag := range redisTlsFlags {
103+
Eventually(redisDepl).Should(deplFixture.HaveContainerCommandSubstring(flag, 0), "Redis missing TLS flag: "+flag)
104+
}
105+
106+
By("verifying the repo-server deployment is configured to use TLS")
107+
repoServerDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-repo-server", Namespace: ns.Name}}
108+
109+
Eventually(repoServerDepl).Should(deplFixture.HaveContainerCommandSubstring("--redis-use-tls", 0))
110+
Eventually(repoServerDepl).Should(deplFixture.HaveContainerCommandSubstring("--redis-ca-certificate /app/config/reposerver/tls/redis/tls.crt", 0))
111+
112+
By("verifying the argocd-server deployment is configured to use TLS")
113+
argocdServerDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-server", Namespace: ns.Name}}
114+
115+
Eventually(argocdServerDepl).Should(deplFixture.HaveContainerCommandSubstring("--redis-use-tls", 0))
116+
Eventually(argocdServerDepl).Should(deplFixture.HaveContainerCommandSubstring("--redis-ca-certificate /app/config/server/tls/redis/tls.crt", 0))
117+
118+
By("verifying the application-controller statefulset is configured to use TLS")
119+
applicationControllerSS := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{Name: "argocd-application-controller", Namespace: ns.Name}}
120+
121+
Eventually(applicationControllerSS).Should(statefulsetFixture.HaveContainerCommandSubstring("--redis-use-tls", 0))
122+
Eventually(applicationControllerSS).Should(statefulsetFixture.HaveContainerCommandSubstring("--redis-ca-certificate /app/config/controller/tls/redis/tls.crt", 0))
123+
})
124+
})
125+
})

0 commit comments

Comments
 (0)