Skip to content

Commit 7ec85b2

Browse files
committed
Address PR comments
1 parent e326312 commit 7ec85b2

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

server/gql/permission_resolver.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ func (r *queryResolver) Tenants(ctx context.Context, limit *int, ids []int) ([]*
140140
continue
141141
}
142142
refs = append(refs, perms.Ref)
143+
if limit != nil && len(refs) >= *limit {
144+
break
145+
}
143146
}
144147
} else {
145148
refs, err = pm.ListObjects(ctx, authz.TenantType)
@@ -171,6 +174,9 @@ func (r *queryResolver) Groups(ctx context.Context, limit *int, ids []int) ([]*m
171174
continue
172175
}
173176
refs = append(refs, perms.Ref)
177+
if limit != nil && len(refs) >= *limit {
178+
break
179+
}
174180
}
175181
} else {
176182
refs, err = pm.ListObjects(ctx, authz.GroupType)

server/gql/permission_resolver_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,22 @@ func TestPermissionResolver_Filtering(t *testing.T) {
561561
assert.NotContains(t, tenantGroups, "HA-group", "traversal should not widen to HA-group")
562562
})
563563

564+
t.Run("partial-user tenant permissions children filtered", func(t *testing.T) {
565+
c := newPermTestClientFromConfig(cfg, "partial-user")
566+
jj := postQuery(t, c, `{ tenants { name permissions { children { type name } } } }`, nil)
567+
for _, tenant := range gjson.Get(jj, "tenants").Array() {
568+
if tenant.Get("name").Str != "tl-tenant" {
569+
continue
570+
}
571+
childNames := names(tenant.Get("permissions.children").Array(), "name")
572+
assert.Contains(t, childNames, "CT-group")
573+
assert.NotContains(t, childNames, "BA-group", "permissions children should not include BA-group")
574+
assert.NotContains(t, childNames, "HA-group", "permissions children should not include HA-group")
575+
return
576+
}
577+
t.Fatal("tl-tenant not found")
578+
})
579+
564580
t.Run("partial-user group feeds", func(t *testing.T) {
565581
c := newPermTestClientFromConfig(cfg, "partial-user")
566582
jj := postQuery(t, c, `{ groups { name feeds { onestop_id } } }`, nil)

0 commit comments

Comments
 (0)