-
Notifications
You must be signed in to change notification settings - Fork 343
Thorough integration tests for index API authorization #5632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ae07568 to
f8c2544
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5632 +/- ##
==========================================
+ Coverage 72.96% 73.10% +0.13%
==========================================
Files 414 412 -2
Lines 25873 26168 +295
Branches 3934 3963 +29
==========================================
+ Hits 18879 19130 +251
- Misses 5083 5147 +64
+ Partials 1911 1891 -20 🚀 New features to boost your workflow:
|
bdecbde to
f5c21bf
Compare
src/integrationTest/java/org/opensearch/security/privileges/int_tests/ClusterConfig.java
Show resolved
Hide resolved
|
Thank you @nibix ! This is quite a large PR (even if only test files). It may make sense to break this up into smaller PRs for sake of review similar to what was done to the |
Well, we have 5 main test classes:
Thus, one could break it down into 5 PRs:
Still, I am not sure if this will be really helpful, as this does not really change the grouping of the changes. Already now, you could review class by class. Also, the test cases themselves are then quite repetetive; if you reviewed the first few test cases, you will likely just skim over the remaining ones. In a few cases, these document some oddities; but in most cases, these will be addressed in the enhanced index resolution PR. In the end, this PR is only a preparation for the next one. |
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
DarshitChanpura
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nibix Given that this is a huge PR i did my best to thoroughly review the PR and have left some comments and clarification questions.
Could this be broken down into smaller PRs? i.e. data-stream, index and snapshot tests individually?
src/integrationTest/java/org/opensearch/test/framework/TestSecurityConfig.java
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/test/framework/matcher/RestIndexMatchers.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/test/framework/matcher/RestIndexMatchers.java
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/test/framework/matcher/RestIndexMatchers.java
Outdated
Show resolved
Hide resolved
| // Additionally, the dnfof implementation has the effect that hidden indices might be included even though not requested | ||
| assertThat( | ||
| httpResponse, | ||
| containsExactly(clusterConfig.systemIndexPrivilegeEnabled ? ALL_INDICES : ALL_INDICES_EXCEPT_SYSTEM_INDICES).at( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will unlimited user see less results than limited users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes (still, both will only see authorized indices), the limited users will just see more than they requested (the request shall request no indices).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this behavior is confusing to me. How would admin cert user end up seeing less results than a limited user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the do_not_fail_on_forbidden mode is active, the security plugin does the following:
- Try to gather from a request which indices are requested. It gets this wrong by always including hidden indices, evenn though they are not requested
- Reduce the indices to the ones where the user is authorized. This may include hidden indices.
- Update the request with the reduced indices. Becausee the reduced indices are based on the set of indices including hidden indices, the hidden indices are now suddenly included in the request, even though originally the were not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i understand that but admin cert should always see same or more number of results than regular user, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that observed behavior is certainly a bug, which we will also fix with the improved index resolution
...st/java/org/opensearch/security/privileges/int_tests/IndexAuthorizationReadOnlyIntTests.java
Show resolved
Hide resolved
...st/java/org/opensearch/security/privileges/int_tests/IndexAuthorizationReadOnlyIntTests.java
Show resolved
Hide resolved
...st/java/org/opensearch/security/privileges/int_tests/IndexAuthorizationReadOnlyIntTests.java
Show resolved
Hide resolved
...st/java/org/opensearch/security/privileges/int_tests/IndexAuthorizationReadOnlyIntTests.java
Show resolved
Hide resolved
Signed-off-by: Nils Bandener <[email protected]>
I am not sure if that would really a big help. The tests regarding data-streams, indexes and snapshots are already grouped in separate files, so one can review them one by one. TBH, I am not sure if it makes sense to review all the individual assertions, as they just assert the present state. Some discover issues, but it is not in the scope of this PR to fix the issues. If you want, we can also arrange a call for a walkthrough through the tests. |
|
@nibix Makes sense. No need for a call as the end of the day it benefits the repo and if tests face any issues down the road we can debug then. I just left few clarifying comments to your answers, once those are addressed I'm happy to approve and merge. |
Signed-off-by: Nils Bandener <[email protected]>
|
@cwperks @DarshitChanpura I pushed some final fixes. Can you re-review please? :) |
|
@nibix The changes look good to me. I did leave one more comment: #5632 (comment) |
Description
This introduces new integration tests for authorization against index APIs.
In order to be as thorough as possible, the test suites use parameters to define several test dimensions:
This is mostly a preparation for #5399; it will give us a good overview over the changed behaviors and allows us to judge whether we want to change a behavior or not.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.