Principal/policy counts seem incorrect
lcouzens opened this issue · comments
Luke Couzens commented
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
- Go to 'api/rbac/v1/groups'
- Create a group
- Add principal to group
- Create role/policy
- Add second user to group
- Check group principal/policy counts
Expected behavior
Counts should match principals and policies independently.
Context (please complete the following information):
- OS: Fedora
- Browser: FireFox
- Commit Hash from status endpoint: "6e05d8cb2ac3f6fa26fe19a1e8797a73bb312e91"
Additional context
{
"uuid": "745ac0cd-b8a3-4a92-a480-bebea168c2e4",
"name": "test_group_PuAKHCGnWX",
"description": "Group for admin tests",
"principalCount": 2,
"policyCount": 2,
"created": "2019-07-15T10:57:00.728610Z",
"modified": "2019-07-15T10:59:33.001129Z"
}
Looking at the code I believe the issue is with Group.objects.annotate here
https://github.com/RedHatInsights/insights-rbac/blob/master/rbac/management/group/view.py#L66
While investigating we found this https://docs.djangoproject.com/en/2.2/topics/db/aggregation/#combining-multiple-aggregations
Chris Hambridge commented
Luke Couzens commented
Verified!