-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Refactor before entitlements for testing #129099
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
Refactor before entitlements for testing #129099
Conversation
It's only called in one place, and there's no need to override it for testing. Removing it just makes things simpler.
Tests in org.elasticsearch.entitlement.bridge are going to be uniquely hard to test once we patch the bridge into java.base, due to Java's prohibition on split packages. Let's just move this guy to another package.
Pinging @elastic/es-core-infra (Team:Core/Infra) |
fbc505f
to
0a04b2e
Compare
In our unit test, we have a mock checker that doesn't extend EntitlementChecker, so downcasting to that would require us to needlessly rework 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'm a bit torn about the PolicyManager change, but I'll not stand in your way if you think it's better and it's going to work.
import static org.elasticsearch.entitlement.BridgeUtilTests.MockSensitiveClass.mockSensitiveMethod; | ||
|
||
/** | ||
* Note: this is not un the bridge package because that is a uniquely bad one to use for tests. |
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.
* Note: this is not un the bridge package because that is a uniquely bad one to use for tests. | |
* Note: this is not in the bridge package because that is a uniquely bad one to use for tests. |
* Since: | ||
* <ol> | ||
* <li> | ||
* we much patch the bridge module into {@code java.base} for it to be reachable |
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.
* we much patch the bridge module into {@code java.base} for it to be reachable | |
* we must patch the bridge module into {@code java.base} for it to be reachable |
...ramework/src/main/java/org/elasticsearch/entitlement/bootstrap/TestEntitlementBootstrap.java
Show resolved
Hide resolved
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Show resolved
Hide resolved
* Support multiple plugin source paths * Refactor: remove unncessary PathLookup method. It's only called in one place, and there's no need to override it for testing. Removing it just makes things simpler. * Refactor: local var for pathLookup * Fix bugs in test build info parsing * Fix representative_class in test * Move BridgeUtilTests. Tests in org.elasticsearch.entitlement.bridge are going to be uniquely hard to test once we patch the bridge into java.base, due to Java's prohibition on split packages. Let's just move this guy to another package. * Upcast (?!) Java23EntitlementChecker to EntitlementChecker * Empty TestPathLookup * Create PolicyManager during bootstrap, allowing us to share initialization * Use empty component path list instead of null * Downcast to the class of the check method. In our unit test, we have a mock checker that doesn't extend EntitlementChecker, so downcasting to that would require us to needlessly rework the unit test. * Fix javadoc typos
💚 Backport successful
|
* Support multiple plugin source paths * Refactor: remove unncessary PathLookup method. It's only called in one place, and there's no need to override it for testing. Removing it just makes things simpler. * Refactor: local var for pathLookup * Fix bugs in test build info parsing * Fix representative_class in test * Move BridgeUtilTests. Tests in org.elasticsearch.entitlement.bridge are going to be uniquely hard to test once we patch the bridge into java.base, due to Java's prohibition on split packages. Let's just move this guy to another package. * Upcast (?!) Java23EntitlementChecker to EntitlementChecker * Empty TestPathLookup * Create PolicyManager during bootstrap, allowing us to share initialization * Use empty component path list instead of null * Downcast to the class of the check method. In our unit test, we have a mock checker that doesn't extend EntitlementChecker, so downcasting to that would require us to needlessly rework the unit test. * Fix javadoc typos
* Support multiple plugin source paths * Refactor: remove unncessary PathLookup method. It's only called in one place, and there's no need to override it for testing. Removing it just makes things simpler. * Refactor: local var for pathLookup * Fix bugs in test build info parsing * Fix representative_class in test * Move BridgeUtilTests. Tests in org.elasticsearch.entitlement.bridge are going to be uniquely hard to test once we patch the bridge into java.base, due to Java's prohibition on split packages. Let's just move this guy to another package. * Upcast (?!) Java23EntitlementChecker to EntitlementChecker * Empty TestPathLookup * Create PolicyManager during bootstrap, allowing us to share initialization * Use empty component path list instead of null * Downcast to the class of the check method. In our unit test, we have a mock checker that doesn't extend EntitlementChecker, so downcasting to that would require us to needlessly rework the unit test. * Fix javadoc typos
This is a sequence of mergeable commits in preparation for further work on enabling entitlements during unit tests.
Reviewers: this could be less daunting if reviewed commit-by-commit.
See ES-11597.