Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,29 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {

// List environment variables with expected values for the principal deployment
expectedEnvVariables = map[string]string{
argocdagent.EnvArgoCDPrincipalLogLevel: "info",
argocdagent.EnvArgoCDPrincipalNamespace: ns.Name,
argocdagent.EnvArgoCDPrincipalAllowedNamespaces: "*",
argocdagent.EnvArgoCDPrincipalNamespaceCreateEnable: "false",
argocdagent.EnvArgoCDPrincipalNamespaceCreatePattern: "",
argocdagent.EnvArgoCDPrincipalNamespaceCreateLabels: "",
argocdagent.EnvArgoCDPrincipalTLSServerAllowGenerate: "true",
argocdagent.EnvArgoCDPrincipalJWTAllowGenerate: "true",
argocdagent.EnvArgoCDPrincipalAuth: "mtls:CN=([^,]+)",
argocdagent.EnvArgoCDPrincipalEnableResourceProxy: "true",
argocdagent.EnvArgoCDPrincipalKeepAliveMinInterval: "30s",
argocdagent.EnvArgoCDPrincipalRedisServerAddress: fmt.Sprintf("%s-%s:%d", argoCDName, "redis", common.ArgoCDDefaultRedisPort),
argocdagent.EnvArgoCDPrincipalRedisCompressionType: "gzip",
argocdagent.EnvArgoCDPrincipalLogFormat: "text",
argocdagent.EnvArgoCDPrincipalEnableWebSocket: "false",
argocdagent.EnvArgoCDPrincipalTLSSecretName: agentPrincipalTLSSecretName,
argocdagent.EnvArgoCDPrincipalTLSServerRootCASecretName: agentRootCASecretName,
argocdagent.EnvArgoCDPrincipalResourceProxySecretName: agentResourceProxyTLSSecretName,
argocdagent.EnvArgoCDPrincipalResourceProxyCaSecretName: agentRootCASecretName,
argocdagent.EnvArgoCDPrincipalJwtSecretName: agentJWTSecretName,
argocdagent.EnvArgoCDPrincipalLogLevel: "info",
argocdagent.EnvArgoCDPrincipalNamespace: ns.Name,
argocdagent.EnvArgoCDPrincipalAllowedNamespaces: "*",
argocdagent.EnvArgoCDPrincipalNamespaceCreateEnable: "false",
argocdagent.EnvArgoCDPrincipalNamespaceCreatePattern: "",
argocdagent.EnvArgoCDPrincipalNamespaceCreateLabels: "",
argocdagent.EnvArgoCDPrincipalTLSServerAllowGenerate: "true",
argocdagent.EnvArgoCDPrincipalJWTAllowGenerate: "true",
argocdagent.EnvArgoCDPrincipalAuth: "mtls:CN=([^,]+)",
argocdagent.EnvArgoCDPrincipalEnableResourceProxy: "true",
argocdagent.EnvArgoCDPrincipalKeepAliveMinInterval: "30s",
argocdagent.EnvArgoCDPrincipalRedisServerAddress: fmt.Sprintf("%s-%s:%d", argoCDName, "redis", common.ArgoCDDefaultRedisPort),
argocdagent.EnvArgoCDPrincipalRedisCompressionType: "gzip",
argocdagent.EnvArgoCDPrincipalLogFormat: "text",
argocdagent.EnvArgoCDPrincipalEnableWebSocket: "false",
argocdagent.EnvArgoCDPrincipalTLSSecretName: agentPrincipalTLSSecretName,
argocdagent.EnvArgoCDPrincipalTLSServerRootCASecretName: agentRootCASecretName,
argocdagent.EnvArgoCDPrincipalResourceProxySecretName: agentResourceProxyTLSSecretName,
argocdagent.EnvArgoCDPrincipalResourceProxyCaSecretName: agentRootCASecretName,
argocdagent.EnvArgoCDPrincipalJwtSecretName: agentJWTSecretName,
argocdagent.EnvArgoCDPrincipalEnableSelfClusterRegistration: "false",
argocdagent.EnvArgoCDPrincipalSelfRegistrationClientCertSecret: "",
argocdagent.EnvArgoCDPrincipalResourceProxyAddress: fmt.Sprintf("%s-agent-principal-resource-proxy:%d", argoCDName, argocdagent.PrincipalResourceProxyServicePort),
}

principalResources = agentFixture.PrincipalResources{
Expand Down Expand Up @@ -984,5 +987,65 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
Consistently(clusterRole, "10s", "2s").Should(k8sFixture.NotExistByName())
Consistently(clusterRoleBinding, "10s", "2s").Should(k8sFixture.NotExistByName())
})

It("should propagate self-registration configuration to principal deployment env vars", func() {
By("Create ArgoCD instance with self-registration enabled")

argoCD.Spec.ArgoCDAgent.Principal.SelfRegistration = &argov1beta1api.PrincipalSelfRegistrationSpec{
Enabled: new(true),
ClientCertSecretName: "argocd-agent-shared-client-cert",
}
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())

By("Verify expected resources are created for principal pod")

verifyExpectedResourcesExist(ns)

By("Verify self-registration environment variables are set correctly")

container := deploymentFixture.GetTemplateSpecContainerByName(argoCDAgentPrincipalName, *principalDeployment)
Expect(container).ToNot(BeNil())

expectedEnvVariables[argocdagent.EnvArgoCDPrincipalEnableSelfClusterRegistration] = "true"
expectedEnvVariables[argocdagent.EnvArgoCDPrincipalSelfRegistrationClientCertSecret] = "argocd-agent-shared-client-cert"

for key, value := range expectedEnvVariables {
Expect(container.Env).To(ContainElement(corev1.EnvVar{Name: key, Value: value}), "Environment variable %s should be set to %s", key, value)
}

By("Update self-registration configuration: disable and change client cert secret")

Expect(k8sClient.Get(ctx, client.ObjectKey{Name: argoCDName, Namespace: ns.Name}, argoCD)).To(Succeed())
argocdFixture.Update(argoCD, func(ac *argov1beta1api.ArgoCD) {
ac.Spec.ArgoCDAgent.Principal.SelfRegistration.Enabled = new(false)
ac.Spec.ArgoCDAgent.Principal.SelfRegistration.ClientCertSecretName = "updated-client-cert"
})

By("Wait for the client cert secret update to propagate, then verify all env vars")

Eventually(func() bool {
err := k8sClient.Get(ctx, client.ObjectKey{Name: argoCDAgentPrincipalName, Namespace: ns.Name}, principalDeployment)
if err != nil {
return false
}
container = deploymentFixture.GetTemplateSpecContainerByName(argoCDAgentPrincipalName, *principalDeployment)
if container == nil {
return false
}
for _, env := range container.Env {
if env.Name == argocdagent.EnvArgoCDPrincipalSelfRegistrationClientCertSecret {
return env.Value == "updated-client-cert"
}
}
return false
}, "120s", "5s").Should(BeTrue(), "Self-registration client cert secret should be updated")

expectedEnvVariables[argocdagent.EnvArgoCDPrincipalEnableSelfClusterRegistration] = "false"
expectedEnvVariables[argocdagent.EnvArgoCDPrincipalSelfRegistrationClientCertSecret] = "updated-client-cert"

for key, value := range expectedEnvVariables {
Expect(container.Env).To(ContainElement(corev1.EnvVar{Name: key, Value: value}), "Environment variable %s should be set to %s", key, value)
}
})
})
})
Loading