Skip to content

Commit 86de107

Browse files
authored
Remove entitlement reflection ITs. (#121550) (#121562)
This is best tested in unit tests, not REST actions.
1 parent bbfa4dc commit 86de107

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/DummyImplementations.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@
5252
* <p>
5353
* A bit like Mockito but way more painful.
5454
*/
55-
public class DummyImplementations {
55+
class DummyImplementations {
56+
57+
static class DummyLocaleServiceProvider extends LocaleServiceProvider {
5658

57-
public static class DummyLocaleServiceProvider extends LocaleServiceProvider {
5859
@Override
5960
public Locale[] getAvailableLocales() {
6061
throw unexpected();

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/RestEntitlementsCheckAction.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ static CheckAction alwaysDenied(CheckedRunnable<Exception> action) {
9696

9797
private static final Map<String, CheckAction> checkActions = Stream.concat(
9898
Stream.<Entry<String, CheckAction>>of(
99-
entry("static_reflection", deniedToPlugins(RestEntitlementsCheckAction::staticMethodNeverEntitledViaReflection)),
100-
entry("nonstatic_reflection", deniedToPlugins(RestEntitlementsCheckAction::nonstaticMethodNeverEntitledViaReflection)),
101-
entry("constructor_reflection", deniedToPlugins(RestEntitlementsCheckAction::constructorNeverEntitledViaReflection)),
10299
entry("runtime_exit", deniedToPlugins(RestEntitlementsCheckAction::runtimeExit)),
103100
entry("runtime_halt", deniedToPlugins(RestEntitlementsCheckAction::runtimeHalt)),
104101
entry("system_exit", deniedToPlugins(RestEntitlementsCheckAction::systemExit)),
@@ -341,11 +338,6 @@ private static void systemExit() {
341338
System.exit(123);
342339
}
343340

344-
private static void staticMethodNeverEntitledViaReflection() throws Exception {
345-
Method systemExit = System.class.getMethod("exit", int.class);
346-
systemExit.invoke(null, 123);
347-
}
348-
349341
private static void createClassLoader() throws IOException {
350342
try (var classLoader = new URLClassLoader("test", new URL[0], RestEntitlementsCheckAction.class.getClassLoader())) {
351343
logger.info("Created URLClassLoader [{}]", classLoader.getName());
@@ -356,11 +348,6 @@ private static void processBuilder_start() throws IOException {
356348
new ProcessBuilder("").start();
357349
}
358350

359-
private static void nonstaticMethodNeverEntitledViaReflection() throws Exception {
360-
Method processBuilderStart = ProcessBuilder.class.getMethod("start");
361-
processBuilderStart.invoke(new ProcessBuilder(""));
362-
}
363-
364351
private static void processBuilder_startPipeline() throws IOException {
365352
ProcessBuilder.startPipeline(List.of());
366353
}
@@ -399,10 +386,6 @@ private static void setHttpsConnectionProperties() {
399386
new DummyLocaleServiceProvider();
400387
}
401388

402-
private static void constructorNeverEntitledViaReflection() throws Exception {
403-
DummyLocaleServiceProvider.class.getConstructor().newInstance();
404-
}
405-
406389
private static void breakIteratorProvider$() {
407390
new DummyBreakIteratorProvider();
408391
}

0 commit comments

Comments
 (0)