@@ -662,6 +662,52 @@ func TestPermissionResolver_Filtering(t *testing.T) {
662662 assert .NotContains (t , groupNames , "HA-group" )
663663 })
664664
665+ t .Run ("partial-user group permissions children filtered" , func (t * testing.T ) {
666+ // Verify resolvePermissions filters children on a non-tenant type (group)
667+ c := newPermTestClientFromConfig (cfg , "partial-user" )
668+ jj := postQuery (t , c , `{ groups { name permissions { children { type name } } } }` , nil )
669+ groups := gjson .Get (jj , "groups" ).Array ()
670+ assert .Equal (t , 1 , len (groups ), "partial-user should see exactly 1 group" )
671+ assert .Equal (t , "CT-group" , groups [0 ].Get ("name" ).Str )
672+ childNames := names (groups [0 ].Get ("permissions.children" ).Array (), "name" )
673+ assert .Contains (t , childNames , "CT" )
674+ assert .NotContains (t , childNames , "BA" , "group permissions children should not include feeds from other groups" )
675+ })
676+
677+ t .Run ("partial-user tenant groups with limit" , func (t * testing.T ) {
678+ // Verify that limit is applied after filtering, not before.
679+ // tl-tenant has 3 groups but partial-user can only see CT-group.
680+ // With limit=1 the user should still get CT-group (not an empty
681+ // result from limiting before filtering).
682+ c := newPermTestClientFromConfig (cfg , "partial-user" )
683+ jj := postQuery (t , c , `{ tenants { name groups(limit: 1) { name } } }` , nil )
684+ for _ , tenant := range gjson .Get (jj , "tenants" ).Array () {
685+ if tenant .Get ("name" ).Str != "tl-tenant" {
686+ continue
687+ }
688+ groupNames := names (tenant .Get ("groups" ).Array (), "name" )
689+ assert .Equal (t , 1 , len (groupNames ), "should return exactly 1 group" )
690+ assert .Contains (t , groupNames , "CT-group" )
691+ return
692+ }
693+ t .Fatal ("tl-tenant not found" )
694+ })
695+
696+ t .Run ("full-user tenant groups with limit" , func (t * testing.T ) {
697+ // full-user can see all 3 groups; limit=2 should cap at 2
698+ c := newPermTestClientFromConfig (cfg , "full-user" )
699+ jj := postQuery (t , c , `{ tenants { name groups(limit: 2) { name } } }` , nil )
700+ for _ , tenant := range gjson .Get (jj , "tenants" ).Array () {
701+ if tenant .Get ("name" ).Str != "tl-tenant" {
702+ continue
703+ }
704+ groupNames := names (tenant .Get ("groups" ).Array (), "name" )
705+ assert .Equal (t , 2 , len (groupNames ), "should return exactly 2 groups" )
706+ return
707+ }
708+ t .Fatal ("tl-tenant not found" )
709+ })
710+
665711 t .Run ("nobody sees nothing" , func (t * testing.T ) {
666712 c := newPermTestClientFromConfig (cfg , "nobody" )
667713 jj := postQuery (t , c , `{ tenants { id } }` , nil )
0 commit comments