eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

FIX - limitExceeded and pagination not working in users by role API 'GET /{scopeId}/roles/{roleId}/users' #4029

Closed Agnul97 closed 4 months ago

Agnul97 commented 4 months ago

Brief description of the PR. I fixed the problem by noticing that, in the rest-api method for the call GET /{scopeId}/roles/{roleId}/users, the limit and offsets parameters were used also in the 2 queries to the "access_info" and "access_role" tables, before querying for the "user" table. This was having unwanted side effects for how we set the limitExceeded parameter and how offsets are used for the pagination.

Other than this, I refactored a bit the code moving a lot of logic inside the new roleService method userIdsByRoleId. I created a test for it as well

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 15.38462% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 16.81%. Comparing base (fc97b10) to head (e3ba726). Report is 15 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4029/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4029?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4029 +/- ## ============================================= + Coverage 16.78% 16.81% +0.02% Complexity 10 10 ============================================= Files 1987 1987 Lines 51835 51850 +15 Branches 4422 4424 +2 ============================================= + Hits 8702 8716 +14 - Misses 42730 42731 +1 Partials 403 403 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4029?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [...rvice/authorization/shiro/AuthorizationModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4029?src=pr&el=tree&filepath=service%2Fsecurity%2Fshiro%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fservice%2Fauthorization%2Fshiro%2FAuthorizationModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9zZWN1cml0eS9zaGlyby9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL3NlcnZpY2UvYXV0aG9yaXphdGlvbi9zaGlyby9BdXRob3JpemF0aW9uTW9kdWxlLmphdmE=) | `84.21% <ø> (+3.50%)` | :arrow_up: | | [...se/kapua/app/api/resources/v1/resources/Roles.java](https://app.codecov.io/gh/eclipse/kapua/pull/4029?src=pr&el=tree&filepath=rest-api%2Fresources%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fapp%2Fapi%2Fresources%2Fv1%2Fresources%2FRoles.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-cmVzdC1hcGkvcmVzb3VyY2VzL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYXBwL2FwaS9yZXNvdXJjZXMvdjEvcmVzb3VyY2VzL1JvbGVzLmphdmE=) | `0.00% <0.00%> (ø)` | | | [...vice/authorization/role/shiro/RoleServiceImpl.java](https://app.codecov.io/gh/eclipse/kapua/pull/4029?src=pr&el=tree&filepath=service%2Fsecurity%2Fshiro%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fservice%2Fauthorization%2Frole%2Fshiro%2FRoleServiceImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9zZWN1cml0eS9zaGlyby9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL3NlcnZpY2UvYXV0aG9yaXphdGlvbi9yb2xlL3NoaXJvL1JvbGVTZXJ2aWNlSW1wbC5qYXZh) | `12.50% <36.36%> (+3.40%)` | :arrow_up: | | [...authorization/steps/AuthorizationServiceSteps.java](https://app.codecov.io/gh/eclipse/kapua/pull/4029?src=pr&el=tree&filepath=service%2Fsecurity%2Ftest-steps%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fservice%2Fauthorization%2Fsteps%2FAuthorizationServiceSteps.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9zZWN1cml0eS90ZXN0LXN0ZXBzL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvc2VydmljZS9hdXRob3JpemF0aW9uL3N0ZXBzL0F1dGhvcml6YXRpb25TZXJ2aWNlU3RlcHMuamF2YQ==) | `0.00% <0.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/eclipse/kapua/pull/4029/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)