@@ -44,7 +44,6 @@ import (
4444)
4545
4646var _ = Describe ("GitOps Operator Sequential E2E Tests" , func () {
47-
4847 const (
4948 argoCDName = "example"
5049 argoCDAgentPrincipalName = "example-agent-principal" // argoCDName + "-agent-principal"
@@ -54,7 +53,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
5453 )
5554
5655 Context ("1-051_validate_argocd_agent_principal" , func () {
57-
5856 var (
5957 k8sClient client.Client
6058 ctx context.Context
@@ -339,7 +337,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
339337 })
340338
341339 It ("should create argocd agent principal resources, and pod should start successfully with default image" , func () {
342-
343340 // Add a custom environment variable to the principal server
344341 argoCD .Spec .ArgoCDAgent .Principal .Env = []corev1.EnvVar {{Name : "TEST_ENV" , Value : "test_value" }}
345342
@@ -401,7 +398,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
401398 })
402399
403400 It ("Should reflect configuration changes from ArgoCD CR to the principal deployment" , func () {
404-
405401 By ("Create ArgoCD instance" )
406402
407403 argoCD .Spec .ArgoCDAgent .Principal .Image = common .ArgoCDAgentPrincipalDefaultImageName
@@ -429,7 +425,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
429425 Expect (k8sClient .Get (ctx , client.ObjectKey {Name : argoCDName , Namespace : ns .Name }, argoCD )).To (Succeed ())
430426
431427 argocdFixture .Update (argoCD , func (ac * argov1beta1api.ArgoCD ) {
432-
433428 ac .Spec .ArgoCDAgent .Principal .LogLevel = "trace"
434429 ac .Spec .ArgoCDAgent .Principal .LogFormat = "json"
435430 ac .Spec .ArgoCDAgent .Principal .Server .KeepAliveMinInterval = "60s"
@@ -452,7 +447,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
452447 SecretName : "argocd-agent-resource-proxy-tls-v2" ,
453448 CASecretName : "argocd-agent-ca-v2" ,
454449 }
455-
456450 })
457451
458452 By ("Create required secrets and certificates for principal pod to start properly" )
@@ -512,7 +506,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
512506 })
513507
514508 It ("should handle route disabled configuration correctly" , func () {
515-
516509 By ("Create ArgoCD instance with route disabled" )
517510
518511 argoCD .Spec .ArgoCDAgent .Principal .Server .Route = argov1beta1api.ArgoCDAgentPrincipalRouteSpec {
@@ -532,7 +525,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
532525 })
533526
534527 It ("should handle route enabled configuration correctly" , func () {
535-
536528 By ("Create ArgoCD instance with route enabled" )
537529
538530 argoCD .Spec .ArgoCDAgent .Principal .Server .Route = argov1beta1api.ArgoCDAgentPrincipalRouteSpec {
@@ -552,7 +544,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
552544 })
553545
554546 It ("should handle route toggle from enabled to disabled correctly" , func () {
555-
556547 By ("Create ArgoCD instance with route enabled" )
557548
558549 argoCD .Spec .ArgoCDAgent .Principal .Server .Route = argov1beta1api.ArgoCDAgentPrincipalRouteSpec {
@@ -618,7 +609,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
618609 })
619610
620611 It ("should handle service type ClusterIP configuration correctly" , func () {
621-
622612 By ("Create ArgoCD instance with service type ClusterIP" )
623613
624614 argoCD .Spec .ArgoCDAgent .Principal .Server .Service = argov1beta1api.ArgoCDAgentPrincipalServiceSpec {
@@ -643,7 +633,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
643633 })
644634
645635 It ("should handle service type LoadBalancer configuration correctly" , func () {
646-
647636 By ("Create ArgoCD instance with service type LoadBalancer" )
648637
649638 argoCD .Spec .ArgoCDAgent .Principal .Server .Service = argov1beta1api.ArgoCDAgentPrincipalServiceSpec {
@@ -668,7 +657,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
668657 })
669658
670659 It ("should handle service type updates correctly" , func () {
671-
672660 By ("Create ArgoCD instance with service type ClusterIP" )
673661
674662 argoCD .Spec .ArgoCDAgent .Principal .Server .Service = argov1beta1api.ArgoCDAgentPrincipalServiceSpec {
@@ -710,7 +698,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
710698 })
711699
712700 It ("should deploy principal via namespace-scoped ArgoCD instance and verify cluster role and cluster role binding are not created" , func () {
713-
714701 By ("Create namespace-scoped ArgoCD instance" )
715702
716703 // Create namespace for hosting namespace-scoped ArgoCD instance with principal
@@ -764,7 +751,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
764751 })
765752
766753 It ("should delete existing cluster role and cluster role binding if ArgoCD instance is namespace-scoped" , func () {
767-
768754 By ("Create namespace-scoped ArgoCD instance namespace" )
769755
770756 // Create namespace for hosting namespace-scoped ArgoCD instance with principal
@@ -908,7 +894,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
908894 })
909895
910896 It ("should create and delete principal ServiceMonitor based on prometheus enabled flag" , func () {
911-
912897 By ("Create ArgoCD instance with principal enabled and prometheus enabled" )
913898
914899 argoCD .Spec .Prometheus .Enabled = true
@@ -955,5 +940,33 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
955940
956941 Eventually (principalServiceMonitor , "2m" , "2s" ).Should (k8sFixture .NotExistByName ())
957942 })
943+
944+ It ("shouldn't create ClusterRole and ClusterRoleBinding for principal if spec.DefaultClusterScopedRoleDisabled is set" , func () {
945+ By ("Create ArgoCD instance with principal enabled and DefaultClusterScopedRoleDisabled is true" )
946+ argoCD .Spec .DefaultClusterScopedRoleDisabled = true
947+ Expect (k8sClient .Create (ctx , argoCD )).To (Succeed ())
948+
949+ By ("Verify ClusterRole and ClusterRoleBinding do not exist" )
950+ Eventually (clusterRole , "60s" , "2s" ).Should (k8sFixture .NotExistByName ())
951+ Eventually (clusterRoleBinding , "60s" , "2s" ).Should (k8sFixture .NotExistByName ())
952+
953+ By ("Namespaced RBAC objects should still exist" )
954+ Eventually (role , "60s" , "2s" ).Should (k8sFixture .ExistByName ())
955+ Eventually (roleBinding , "60s" , "2s" ).Should (k8sFixture .ExistByName ())
956+
957+ By ("Unset DefaultClusterScopedRoleDisabled and make sure cluster scoped RBAC objects are created" )
958+ argocdFixture .Update (argoCD , func (ac * argov1beta1api.ArgoCD ) {
959+ ac .Spec .DefaultClusterScopedRoleDisabled = false
960+ })
961+ Eventually (clusterRole , "60s" , "2s" ).Should (k8sFixture .ExistByName ())
962+ Eventually (clusterRoleBinding , "60s" , "2s" ).Should (k8sFixture .ExistByName ())
963+
964+ By ("Setting DefaultClusterScopedRoleDisabled again deletes clusterRole and clusterRoleBinding" )
965+ argocdFixture .Update (argoCD , func (ac * argov1beta1api.ArgoCD ) {
966+ ac .Spec .DefaultClusterScopedRoleDisabled = true
967+ })
968+ Eventually (clusterRole , "60s" , "2s" ).Should (k8sFixture .NotExistByName ())
969+ Eventually (clusterRoleBinding , "60s" , "2s" ).Should (k8sFixture .NotExistByName ())
970+ })
958971 })
959972})
0 commit comments