Fix #180. Filter properly user rules in RESTServiceImpl #181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Actually Access rules from
ResourceDAOImpl.findUserSecurityRule
returns all rules available instead of returning rules that match user and .RESTServiceImpl
expects only to find only one result (that is not properly correct because there is not any check about unique rules for same user/resource), so it gets the first rule available and checks this rule to find out read or write access information. But because of the bug above, any rule found on the db before the user's one is valid. So it returns true anyway.I changed this behavior to check all rules returned by the ResourceDAOImpl and ignore the ones not referred to the user.
NOTE: I implemented a fix that ignores not valid rules in
RESTServiceImpl
because this part is testable ( test ResourceDAOImpl is hard instead) and becauseResourceDAOImpl.findUserSecurityRule
is deprecated, so it's not too useful maintain it.