@@ -729,7 +729,10 @@ func TestReconcilePGBackRestRBAC(t *testing.T) {
729729}
730730
731731func TestReconcileRepoHostRBAC (t * testing.T ) {
732-
732+ // Garbage collector cleans up test resources before the test completes
733+ if strings .EqualFold (os .Getenv ("USE_EXISTING_CLUSTER" ), "true" ) {
734+ t .Skip ("USE_EXISTING_CLUSTER: Test fails due to garbage collection" )
735+ }
733736 ctx := context .Background ()
734737 _ , tClient := setupKubernetes (t )
735738 require .ParallelCapacity (t , 0 )
@@ -768,6 +771,30 @@ func TestReconcileRepoHostRBAC(t *testing.T) {
768771 }, sa )
769772 assert .NilError (t , err )
770773 assert .DeepEqual (t , sa .Annotations , annotations )
774+
775+ role := & rbacv1.Role {}
776+ err = tClient .Get (ctx , types.NamespacedName {
777+ Name : naming .RepoHostRBAC (postgresCluster ).Name ,
778+ Namespace : postgresCluster .GetNamespace (),
779+ }, role )
780+ assert .NilError (t , err )
781+ assert .Assert (t , len (role .Rules ) > 0 )
782+
783+ roleBinding := & rbacv1.RoleBinding {}
784+ err = tClient .Get (ctx , types.NamespacedName {
785+ Name : naming .RepoHostRBAC (postgresCluster ).Name ,
786+ Namespace : postgresCluster .GetNamespace (),
787+ }, roleBinding )
788+ assert .NilError (t , err )
789+ assert .Assert (t , roleBinding .RoleRef .Name == role .GetName ())
790+
791+ var foundSubject bool
792+ for _ , subject := range roleBinding .Subjects {
793+ if subject .Name == sa .GetName () {
794+ foundSubject = true
795+ }
796+ }
797+ assert .Assert (t , foundSubject )
771798}
772799
773800func TestReconcileStanzaCreate (t * testing.T ) {
0 commit comments