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.
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
Mandate X-Pack REST handler installed #71061
Mandate X-Pack REST handler installed #71061
Changes from 20 commits
a19e287
8bc8643
7fe071c
e6b1581
f707583
b7bb95b
b18a6be
cc5bce6
b1b00f0
d0f0252
a0fba39
065fb8e
75dc96b
0e99823
9fd1481
6e176b4
7651421
e3f28ff
b1b51fd
7ca2084
6bfc65c
80d75b3
356636d
e90511c
16dcd6c
5713478
4a8aa48
4fa2895
81b64d3
f729748
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Per #73329, there should be tests for this functionality in ActionModuleTests.
Core shouldn't rely on x-pack to do its testing for it.
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.
Moved it to ActionModuleTests
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 am not a fan of this test. As an unit test, I think it mixes two things:
Security
- Ensure a non-null restWrapper is always return bygetRestHandlerWrapper
.ActionModule
- Ensure only restWrapper fromSecurity
can be installedEach of the above can be tested independantly in a more unit-test-like fashion. And if we want to test the real thing, we can go for internal or external cluster.
But I am happy to let it pass if Tim is OK with it.
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.
Testing the ActionModule is tricky unless we change how it works. It has a hardcoded dependency on a particular classname, so it's impossible to mock it out (see #73329).
We could soften that check to only check for the package name (
org.elasticsearch.xpack.security
), or to pass the name of the allowed plugin into the constructor. Either of those would then allow it to be tested in a more unit-test-like fashion. Otherwise the strict class-name dependency makes it difficultThere 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.
The check is now relaxed to be package name. Do you think it is worth to have more unit test like tests?
Technically, even with the previous check for exact class name, it is possible to have an unit test for
ActionModule
: SinceActionModule
is in a different module and does not depend on xpack security, it is possible to create a stuborg.elasticsearch.xpack.security.Security
class in its test package and use that for the unit test.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 think it's testing 2 things, and I think it would be better if they were split into
testSecurityPluginInstallsRestHandlerWrapperEvenIfSecurityIsDisabled
which can simply be a test thatSecurity.getRestHandlerWrapper()
returns non-null even when disabled.testSecurityRestHandlerWrapperCanBeInstalled()
which tests that ActionModule doesn't reject the wrapper installed by security (essentially this test).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.
Is this needed?
I think you can skip all the
ActionModule
part since this is a simple unit test onSecurity
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 belongs in
ActionModuleTests
, it's a testing the behaviour ofActionModule
, so it shouldn't be here.