-
Notifications
You must be signed in to change notification settings - Fork 337
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
base: main
Are you sure you want to change the base?
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
* The test suites run on different cluster configurations; the possible cluster configurations are defined here. | ||
*/ | ||
public enum ClusterConfig { | ||
LEGACY_PRIVILEGES_EVALUATION( |
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.
To make sure I understand correctly, legacy
here is related to how DNFOF relates to system index authorization?
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.
Good point.
The naming is already in anticipation of the enhanced privilege evaluation PR which introduces one further element to the enum; thus, the enum looks like this:
security/src/integrationTest/java/org/opensearch/security/privileges/int_tests/ClusterConfig.java
Lines 20 to 38 in b3e2cca
public enum ClusterConfig { | |
LEGACY_PRIVILEGES_EVALUATION( | |
"legacy", | |
c -> c.doNotFailOnForbidden(true).nodeSettings(Map.of("plugins.security.system_indices.enabled", true)), | |
true, | |
false, | |
false | |
), | |
LEGACY_PRIVILEGES_EVALUATION_SYSTEM_INDEX_PERMISSION( | |
"legacy_system_index_perm", | |
c -> c.doNotFailOnForbidden(true) | |
.nodeSettings( | |
Map.of("plugins.security.system_indices.enabled", true, "plugins.security.system_indices.permission.enabled", true) | |
), | |
true, | |
true, | |
false | |
), | |
NEXT_GEN_PRIVILEGES_EVALUATION("next_gen", c -> c.privilegesEvaluationType("next_gen"), false, true, true); |
Thus, currently, this is not really legacy. But maybe we can keep it this way, as it is only temporary and avoids lots of renaming?
But, generally, I am also not sure about a good way to name these things. Also I am not too happy about this "next_gen" name.
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]>
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
} | ||
|
||
if (response.getStatusCode() != 200) { | ||
return true; |
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.
why return true on non 200 code? is it because of empty list of indices and non-existent status code entry ?
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 is the case that an empty set of indices is expected.
If we have a 200 response, we have a valid response and can check this in the response body. But if we do not have 200 response, we must/can just assume that we did not get any indices and stop without further checks.
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.
...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]>
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.