From aba3f15d81047e6962440847344341494aa55ab6 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Fri, 12 Jan 2018 15:34:28 -0500 Subject: [PATCH] Add adding ability to associate an ID with tasks (elastic/x-pack-elasticsearch#3500) X-Pack portion of elastic/elasticsearch#23250 Original commit: elastic/x-pack-elasticsearch@3c9a5d2d08bdeed8d6f800753152d93eaf75fe4d --- .../xpack/ml/action/DeleteJobAction.java | 5 ++- .../persistence/JobStorageDeletionTask.java | 5 ++- .../persistent/AllocatedPersistentTask.java | 6 ++- .../persistent/PersistentTasksExecutor.java | 5 ++- .../PersistentTasksNodeService.java | 4 +- .../upgrade/actions/IndexUpgradeAction.java | 5 ++- .../ml/action/TransportOpenJobAction.java | 9 +++-- .../action/TransportStartDatafeedAction.java | 11 +++-- .../action/TransportXPackInfoActionTests.java | 3 +- .../ml/action/StartDatafeedActionTests.java | 3 +- .../PersistentTasksNodeServiceTests.java | 40 ++++++++++++++----- .../persistent/TestPersistentTasksPlugin.java | 9 +++-- .../role/TransportDeleteRoleActionTests.java | 7 ++-- .../role/TransportGetRolesActionTests.java | 8 ++-- .../role/TransportPutRoleActionTests.java | 7 ++-- .../TransportGetRoleMappingsActionTests.java | 2 +- .../TransportPutRoleMappingActionTests.java | 2 +- .../TransportAuthenticateActionTests.java | 7 ++-- .../TransportChangePasswordActionTests.java | 9 +++-- .../user/TransportDeleteUserActionTests.java | 11 ++--- .../user/TransportGetUsersActionTests.java | 12 +++--- .../TransportHasPrivilegesActionTests.java | 2 +- .../user/TransportPutUserActionTests.java | 10 ++--- .../user/TransportSetEnabledActionTests.java | 11 ++--- 24 files changed, 117 insertions(+), 76 deletions(-) diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/DeleteJobAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/DeleteJobAction.java index a6da6d576f2..ae5d5ebb11a 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/DeleteJobAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/action/DeleteJobAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.xpack.ml.job.persistence.JobStorageDeletionTask; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; import java.io.IOException; +import java.util.Map; import java.util.Objects; public class DeleteJobAction extends Action { @@ -75,8 +76,8 @@ public class DeleteJobAction extends Action headers) { + return new JobStorageDeletionTask(id, type, action, "delete-job-" + jobId, parentTaskId, headers); } @Override diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java index a2749064309..78865121e20 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java @@ -40,6 +40,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Consumer; @@ -53,8 +54,8 @@ import static org.elasticsearch.xpack.ClientHelper.executeAsyncWithOrigin; public class JobStorageDeletionTask extends Task { private final Logger logger; - public JobStorageDeletionTask(long id, String type, String action, String description, TaskId parentTask) { - super(id, type, action, description, parentTask); + public JobStorageDeletionTask(long id, String type, String action, String description, TaskId parentTask, Map headers) { + super(id, type, action, description, parentTask, headers); this.logger = Loggers.getLogger(getClass()); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/AllocatedPersistentTask.java b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/AllocatedPersistentTask.java index 40cf9cc9fd0..353f7ab9495 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/AllocatedPersistentTask.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/AllocatedPersistentTask.java @@ -17,6 +17,7 @@ import org.elasticsearch.tasks.TaskCancelledException; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskManager; +import java.util.Map; import java.util.concurrent.atomic.AtomicReference; /** @@ -35,8 +36,9 @@ public class AllocatedPersistentTask extends CancellableTask { private volatile TaskManager taskManager; - public AllocatedPersistentTask(long id, String type, String action, String description, TaskId parentTask) { - super(id, type, action, description, parentTask); + public AllocatedPersistentTask(long id, String type, String action, String description, TaskId parentTask, + Map headers) { + super(id, type, action, description, parentTask, headers); this.state = new AtomicReference<>(State.STARTED); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutor.java b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutor.java index 4fe04febb07..f15db609787 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutor.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksExecutor.java @@ -15,6 +15,7 @@ import org.elasticsearch.tasks.TaskId; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Assignment; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.PersistentTask; +import java.util.Map; import java.util.function.Predicate; /** @@ -88,8 +89,8 @@ public abstract class PersistentTasksExecutor taskInProgress) { - return new AllocatedPersistentTask(id, type, action, getDescription(taskInProgress), parentTaskId); + PersistentTask taskInProgress, Map headers) { + return new AllocatedPersistentTask(id, type, action, getDescription(taskInProgress), parentTaskId, headers); } /** diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeService.java b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeService.java index 49246a8be20..36907afbe60 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeService.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeService.java @@ -147,8 +147,8 @@ public class PersistentTasksNodeService extends AbstractComponent implements Clu } @Override - public Task createTask(long id, String type, String action, TaskId parentTaskId) { - return executor.createTask(id, type, action, parentTaskId, taskInProgress); + public Task createTask(long id, String type, String action, TaskId parentTaskId, Map headers) { + return executor.createTask(id, type, action, parentTaskId, taskInProgress, headers); } }; AllocatedPersistentTask task = (AllocatedPersistentTask) taskManager.register("persistent", taskInProgress.getTaskName() + "[c]", diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeAction.java index 58486680817..7daa9525bd1 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/upgrade/actions/IndexUpgradeAction.java @@ -20,6 +20,7 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import java.io.IOException; +import java.util.Map; import java.util.Objects; import static org.elasticsearch.action.ValidateActions.addValidationError; @@ -138,8 +139,8 @@ public class IndexUpgradeAction extends Action headers) { + return new CancellableTask(id, type, action, getDescription(), parentTaskId, headers) { @Override public boolean shouldCancelChildrenOnCancellation() { return true; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java index 8695d5be9c4..a31c89858c3 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java @@ -591,8 +591,9 @@ public class TransportOpenJobAction extends TransportMasterNodeAction persistentTask) { - return new JobTask(persistentTask.getParams().getJobId(), id, type, action, parentTaskId); + PersistentTasksCustomMetaData.PersistentTask persistentTask, + Map headers) { + return new JobTask(persistentTask.getParams().getJobId(), id, type, action, parentTaskId, headers); } void setMaxConcurrentJobAllocations(int maxConcurrentJobAllocations) { @@ -613,8 +614,8 @@ public class TransportOpenJobAction extends TransportMasterNodeAction headers) { + super(id, type, action, "job-" + jobId, parentTask, headers); this.jobId = jobId; } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java index 96761189ccd..87c266f1626 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java @@ -46,6 +46,7 @@ import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.persistent.PersistentTasksExecutor; import org.elasticsearch.xpack.persistent.PersistentTasksService; +import java.util.Map; import java.util.function.Predicate; /* This class extends from TransportMasterNodeAction for cluster state observing purposes. @@ -222,8 +223,9 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction persistentTask) { - return new DatafeedTask(id, type, action, parentTaskId, persistentTask.getParams()); + PersistentTasksCustomMetaData.PersistentTask persistentTask, + Map headers) { + return new DatafeedTask(id, type, action, parentTaskId, persistentTask.getParams(), headers); } } @@ -235,8 +237,9 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction headers) { + super(id, type, action, "datafeed-" + params.getDatafeedId(), parentTaskId, headers); this.datafeedId = params.getDatafeedId(); this.startTime = params.getStartTime(); this.endTime = params.getEndTime(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java index c7e13b6449f..d6767c4514a 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.XPackFeatureSet; import org.elasticsearch.license.XPackInfoResponse.FeatureSetsInfo.FeatureSet; +import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.Locale; @@ -53,7 +54,7 @@ public class TransportXPackInfoActionTests extends ESTestCase { } TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportXPackInfoAction action = new TransportXPackInfoAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), licenseService, featureSets); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java index 2a3a95aee0c..fbca7361573 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/StartDatafeedActionTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData; +import java.util.Collections; import java.util.Date; import static org.elasticsearch.xpack.ml.action.OpenJobActionTests.addJobTask; @@ -87,7 +88,7 @@ public class StartDatafeedActionTests extends ESTestCase { StartDatafeedAction.DatafeedParams params, DatafeedManager datafeedManager) { TransportStartDatafeedAction.DatafeedTask task = new TransportStartDatafeedAction.DatafeedTask(id, type, action, parentTaskId, - params); + params, Collections.emptyMap()); task.datafeedManager = datafeedManager; return task; } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java index ec049e088a4..b6165777358 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/PersistentTasksNodeServiceTests.java @@ -21,11 +21,14 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskManager; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.Assignment; import org.elasticsearch.xpack.persistent.PersistentTasksCustomMetaData.PersistentTask; import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestParams; import org.elasticsearch.xpack.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; +import org.junit.After; +import org.junit.Before; import java.io.IOException; import java.util.ArrayList; @@ -47,6 +50,23 @@ import static org.mockito.Mockito.when; public class PersistentTasksNodeServiceTests extends ESTestCase { + private ThreadPool threadPool; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + threadPool = new TestThreadPool(getClass().getName()); + } + + + @Override + @After + public void tearDown() throws Exception { + terminate(threadPool); + super.tearDown(); + } + private ClusterState createInitialClusterState(int nonLocalNodesCount, Settings settings) { ClusterState.Builder state = ClusterState.builder(new ClusterName("PersistentActionExecutorTests")); state.metaData(MetaData.builder().generateClusterUuidIfNeeded()); @@ -70,14 +90,14 @@ public class PersistentTasksNodeServiceTests extends ESTestCase { // need to account for 5 original tasks on each node and their relocations for (int i = 0; i < (nonLocalNodesCount + 1) * 10; i++) { TaskId parentId = new TaskId("cluster", i); - when(action.createTask(anyLong(), anyString(), anyString(), eq(parentId), any())).thenReturn( - new TestPersistentTasksPlugin.TestTask(i, "persistent", "test", "", parentId)); + when(action.createTask(anyLong(), anyString(), anyString(), eq(parentId), any(), any())).thenReturn( + new TestPersistentTasksPlugin.TestTask(i, "persistent", "test", "", parentId, Collections.emptyMap())); } PersistentTasksExecutorRegistry registry = new PersistentTasksExecutorRegistry(Settings.EMPTY, Collections.singletonList(action)); MockExecutor executor = new MockExecutor(); PersistentTasksNodeService coordinator = new PersistentTasksNodeService(Settings.EMPTY, persistentTasksService, - registry, new TaskManager(Settings.EMPTY), executor); + registry, new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()), executor); ClusterState state = createInitialClusterState(nonLocalNodesCount, Settings.EMPTY); @@ -161,13 +181,14 @@ public class PersistentTasksNodeServiceTests extends ESTestCase { when(action.getExecutor()).thenReturn(ThreadPool.Names.SAME); when(action.getTaskName()).thenReturn(TestPersistentTasksExecutor.NAME); TaskId parentId = new TaskId("cluster", 1); - AllocatedPersistentTask nodeTask = new TestPersistentTasksPlugin.TestTask(0, "persistent", "test", "", parentId); - when(action.createTask(anyLong(), anyString(), anyString(), eq(parentId), any())).thenReturn(nodeTask); + AllocatedPersistentTask nodeTask = + new TestPersistentTasksPlugin.TestTask(0, "persistent", "test", "", parentId, Collections.emptyMap()); + when(action.createTask(anyLong(), anyString(), anyString(), eq(parentId), any(), any())).thenReturn(nodeTask); PersistentTasksExecutorRegistry registry = new PersistentTasksExecutorRegistry(Settings.EMPTY, Collections.singletonList(action)); MockExecutor executor = new MockExecutor(); PersistentTasksNodeService coordinator = new PersistentTasksNodeService(Settings.EMPTY, persistentTasksService, - registry, new TaskManager(Settings.EMPTY), executor); + registry, new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()), executor); ClusterState state = createInitialClusterState(1, Settings.EMPTY); @@ -209,13 +230,14 @@ public class PersistentTasksNodeServiceTests extends ESTestCase { @SuppressWarnings("unchecked") PersistentTasksExecutor action = mock(PersistentTasksExecutor.class); when(action.getExecutor()).thenReturn(ThreadPool.Names.SAME); when(action.getTaskName()).thenReturn("test"); - when(action.createTask(anyLong(), anyString(), anyString(), any(), any())) - .thenReturn(new TestPersistentTasksPlugin.TestTask(1, "persistent", "test", "", new TaskId("cluster", 1))); + when(action.createTask(anyLong(), anyString(), anyString(), any(), any(), any())) + .thenReturn(new TestPersistentTasksPlugin.TestTask(1, "persistent", "test", "", new TaskId("cluster", 1), + Collections.emptyMap())); PersistentTasksExecutorRegistry registry = new PersistentTasksExecutorRegistry(Settings.EMPTY, Collections.singletonList(action)); int nonLocalNodesCount = randomInt(10); MockExecutor executor = new MockExecutor(); - TaskManager taskManager = new TaskManager(Settings.EMPTY); + TaskManager taskManager = new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet()); PersistentTasksNodeService coordinator = new PersistentTasksNodeService(Settings.EMPTY, persistentTasksService, registry, taskManager, executor); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java b/plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java index b331e8bdc14..a4638961449 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/persistent/TestPersistentTasksPlugin.java @@ -57,6 +57,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -370,8 +371,8 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin { @Override protected AllocatedPersistentTask createTask(long id, String type, String action, TaskId parentTaskId, - PersistentTask task) { - return new TestTask(id, type, action, getDescription(task), parentTaskId); + PersistentTask task, Map headers) { + return new TestTask(id, type, action, getDescription(task), parentTaskId, headers); } } @@ -399,8 +400,8 @@ public class TestPersistentTasksPlugin extends Plugin implements ActionPlugin { public static class TestTask extends AllocatedPersistentTask { private volatile String operation; - public TestTask(long id, String type, String action, String description, TaskId parentTask) { - super(id, type, action, description, parentTask); + public TestTask(long id, String type, String action, String description, TaskId parentTask, Map headers) { + super(id, type, action, description, parentTask, headers); } public String getOperation() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java index cb9b51ad0f8..591173c1713 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportDeleteRoleActionTests.java @@ -19,6 +19,7 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.ArrayList; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -41,7 +42,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase { final String roleName = randomFrom(new ArrayList<>(ReservedRolesStore.names())); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - (x) -> null, null); + (x) -> null, null, Collections.emptySet()); TransportDeleteRoleAction action = new TransportDeleteRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); @@ -72,7 +73,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase { final String roleName = randomFrom("admin", "dept_a", "restricted"); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - (x) -> null, null); + (x) -> null, null, Collections.emptySet()); TransportDeleteRoleAction action = new TransportDeleteRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); @@ -116,7 +117,7 @@ public class TransportDeleteRoleActionTests extends ESTestCase { final String roleName = randomFrom("admin", "dept_a", "restricted"); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - (x) -> null, null); + (x) -> null, null, Collections.emptySet()); TransportDeleteRoleAction action = new TransportDeleteRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java index 457a3dd3fd4..f755097cac6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportGetRolesActionTests.java @@ -42,7 +42,7 @@ public class TransportGetRolesActionTests extends ESTestCase { public void testReservedRoles() { NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetRolesAction action = new TransportGetRolesAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService, new ReservedRolesStore()); @@ -88,7 +88,7 @@ public class TransportGetRolesActionTests extends ESTestCase { final List storeRoleDescriptors = randomRoleDescriptors(); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetRolesAction action = new TransportGetRolesAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService, new ReservedRolesStore()); @@ -140,7 +140,7 @@ public class TransportGetRolesActionTests extends ESTestCase { NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetRolesAction action = new TransportGetRolesAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService, new ReservedRolesStore()); @@ -204,7 +204,7 @@ public class TransportGetRolesActionTests extends ESTestCase { final List storeRoleDescriptors = randomRoleDescriptors(); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetRolesAction action = new TransportGetRolesAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService, new ReservedRolesStore()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java index 093a88822ab..c25308345ab 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/role/TransportPutRoleActionTests.java @@ -20,6 +20,7 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.ArrayList; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -42,7 +43,7 @@ public class TransportPutRoleActionTests extends ESTestCase { final String roleName = randomFrom(new ArrayList<>(ReservedRolesStore.names())); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutRoleAction action = new TransportPutRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); @@ -73,7 +74,7 @@ public class TransportPutRoleActionTests extends ESTestCase { final String roleName = randomFrom("admin", "dept_a", "restricted"); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutRoleAction action = new TransportPutRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); @@ -117,7 +118,7 @@ public class TransportPutRoleActionTests extends ESTestCase { final String roleName = randomFrom("admin", "dept_a", "restricted"); NativeRolesStore rolesStore = mock(NativeRolesStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutRoleAction action = new TransportPutRoleAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), rolesStore, transportService); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java index ea6942b6574..0cc1ff4be10 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportGetRoleMappingsActionTests.java @@ -45,7 +45,7 @@ public class TransportGetRoleMappingsActionTests extends ESTestCase { public void setupMocks() { store = mock(NativeRoleMappingStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, - TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null); + TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet()); action = new TransportGetRoleMappingsAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), transportService, store); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java index 42685479679..36bc614e6ad 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/rolemapping/TransportPutRoleMappingActionTests.java @@ -40,7 +40,7 @@ public class TransportPutRoleMappingActionTests extends ESTestCase { public void setupMocks() { store = mock(NativeRoleMappingStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, - TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null); + TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet()); action = new TransportPutRoleMappingAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), transportService, store); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java index 9468fddb579..138b6284b1d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportAuthenticateActionTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.security.user.XPackUser; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -36,7 +37,7 @@ public class TransportAuthenticateActionTests extends ESTestCase { SecurityContext securityContext = mock(SecurityContext.class); when(securityContext.getUser()).thenReturn(randomFrom(SystemUser.INSTANCE, XPackUser.INSTANCE)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportAuthenticateAction action = new TransportAuthenticateAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), securityContext); @@ -62,7 +63,7 @@ public class TransportAuthenticateActionTests extends ESTestCase { public void testNullUser() { SecurityContext securityContext = mock(SecurityContext.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportAuthenticateAction action = new TransportAuthenticateAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), securityContext); @@ -90,7 +91,7 @@ public class TransportAuthenticateActionTests extends ESTestCase { SecurityContext securityContext = mock(SecurityContext.class); when(securityContext.getUser()).thenReturn(user); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportAuthenticateAction action = new TransportAuthenticateAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), securityContext); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java index 42745a6264b..00738e9d360 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.xpack.security.user.XPackUser; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -48,7 +49,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { AnonymousUser anonymousUser = new AnonymousUser(settings); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportChangePasswordAction action = new TransportChangePasswordAction(settings, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -79,7 +80,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { public void testInternalUsers() { NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportChangePasswordAction action = new TransportChangePasswordAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -121,7 +122,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { return null; }).when(usersStore).changePassword(eq(request), any(ActionListener.class)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportChangePasswordAction action = new TransportChangePasswordAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -162,7 +163,7 @@ public class TransportChangePasswordActionTests extends ESTestCase { } }).when(usersStore).changePassword(eq(request), any(ActionListener.class)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportChangePasswordAction action = new TransportChangePasswordAction(Settings.EMPTY, mock(ThreadPool.class), transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java index db3a938b99a..679d0dc9bcf 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserActionTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.xpack.security.user.XPackUser; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -45,7 +46,7 @@ public class TransportDeleteUserActionTests extends ESTestCase { Settings settings = Settings.builder().put(AnonymousUser.ROLES_SETTING.getKey(), "superuser").build(); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportDeleteUserAction action = new TransportDeleteUserAction(settings, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -74,7 +75,7 @@ public class TransportDeleteUserActionTests extends ESTestCase { public void testInternalUser() { NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportDeleteUserAction action = new TransportDeleteUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -104,7 +105,7 @@ public class TransportDeleteUserActionTests extends ESTestCase { final User reserved = randomFrom(new ElasticUser(true), new KibanaUser(true)); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportDeleteUserAction action = new TransportDeleteUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -134,7 +135,7 @@ public class TransportDeleteUserActionTests extends ESTestCase { final User user = new User("joe"); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportDeleteUserAction action = new TransportDeleteUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -175,7 +176,7 @@ public class TransportDeleteUserActionTests extends ESTestCase { final User user = new User("joe"); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportDeleteUserAction action = new TransportDeleteUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java index c2a6b731945..50527445749 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersActionTests.java @@ -80,7 +80,7 @@ public class TransportGetUsersActionTests extends ESTestCase { ReservedRealm reservedRealm = new ReservedRealm(mock(Environment.class), settings, usersStore, anonymousUser, securityLifecycleService, new ThreadContext(Settings.EMPTY)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, reservedRealm); @@ -115,7 +115,7 @@ public class TransportGetUsersActionTests extends ESTestCase { public void testInternalUser() { NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, mock(ReservedRealm.class)); @@ -158,7 +158,7 @@ public class TransportGetUsersActionTests extends ESTestCase { final List reservedUsers = randomSubsetOf(size, allReservedUsers); final List names = reservedUsers.stream().map(User::principal).collect(Collectors.toList()); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, reservedRealm); @@ -198,7 +198,7 @@ public class TransportGetUsersActionTests extends ESTestCase { ReservedRealm reservedRealm = new ReservedRealm(mock(Environment.class), settings, usersStore, new AnonymousUser(settings), securityLifecycleService, new ThreadContext(Settings.EMPTY)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, reservedRealm); @@ -245,7 +245,7 @@ public class TransportGetUsersActionTests extends ESTestCase { final String[] storeUsernames = storeUsers.stream().map(User::principal).collect(Collectors.toList()).toArray(Strings.EMPTY_ARRAY); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, mock(ReservedRealm.class)); @@ -293,7 +293,7 @@ public class TransportGetUsersActionTests extends ESTestCase { final String[] storeUsernames = storeUsers.stream().map(User::principal).collect(Collectors.toList()).toArray(Strings.EMPTY_ARRAY); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportGetUsersAction action = new TransportGetUsersAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService, mock(ReservedRealm.class)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java index afa12b9ce14..588702a7956 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportHasPrivilegesActionTests.java @@ -58,7 +58,7 @@ public class TransportHasPrivilegesActionTests extends ESTestCase { final ThreadContext threadContext = new ThreadContext(Settings.EMPTY); final TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService .NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); final Authentication authentication = mock(Authentication.class); threadContext.putTransient(AuthenticationField.AUTHENTICATION_KEY, authentication); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java index 7eb4cb00932..e5cd778ce79 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportPutUserActionTests.java @@ -56,7 +56,7 @@ public class TransportPutUserActionTests extends ESTestCase { final AnonymousUser anonymousUser = new AnonymousUser(settings); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutUserAction action = new TransportPutUserAction(settings, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -86,7 +86,7 @@ public class TransportPutUserActionTests extends ESTestCase { public void testSystemUser() { NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutUserAction action = new TransportPutUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -125,7 +125,7 @@ public class TransportPutUserActionTests extends ESTestCase { reservedRealm.users(userFuture); final User reserved = randomFrom(userFuture.actionGet().toArray(new User[0])); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutUserAction action = new TransportPutUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -155,7 +155,7 @@ public class TransportPutUserActionTests extends ESTestCase { final User user = new User("joe"); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutUserAction action = new TransportPutUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); @@ -201,7 +201,7 @@ public class TransportPutUserActionTests extends ESTestCase { final User user = new User("joe"); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportPutUserAction action = new TransportPutUserAction(Settings.EMPTY, mock(ThreadPool.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore, transportService); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java index 2739542f56e..64c57f0a369 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java @@ -27,6 +27,7 @@ import org.elasticsearch.xpack.security.user.XPackUser; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; @@ -60,7 +61,7 @@ public class TransportSetEnabledActionTests extends ESTestCase { when(authentication.getUser()).thenReturn(user); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportSetEnabledAction action = new TransportSetEnabledAction(settings, threadPool, transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -98,7 +99,7 @@ public class TransportSetEnabledActionTests extends ESTestCase { when(authentication.getUser()).thenReturn(user); NativeUsersStore usersStore = mock(NativeUsersStore.class); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportSetEnabledAction action = new TransportSetEnabledAction(Settings.EMPTY, threadPool, transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -152,7 +153,7 @@ public class TransportSetEnabledActionTests extends ESTestCase { }).when(usersStore) .setEnabled(eq(user.principal()), eq(request.enabled()), eq(request.getRefreshPolicy()), any(ActionListener.class)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportSetEnabledAction action = new TransportSetEnabledAction(Settings.EMPTY, threadPool, transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -204,7 +205,7 @@ public class TransportSetEnabledActionTests extends ESTestCase { }).when(usersStore) .setEnabled(eq(user.principal()), eq(request.enabled()), eq(request.getRefreshPolicy()), any(ActionListener.class)); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportSetEnabledAction action = new TransportSetEnabledAction(Settings.EMPTY, threadPool, transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore); @@ -244,7 +245,7 @@ public class TransportSetEnabledActionTests extends ESTestCase { request.enabled(randomBoolean()); request.setRefreshPolicy(randomFrom(RefreshPolicy.values())); TransportService transportService = new TransportService(Settings.EMPTY, null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - x -> null, null); + x -> null, null, Collections.emptySet()); TransportSetEnabledAction action = new TransportSetEnabledAction(Settings.EMPTY, threadPool, transportService, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), usersStore);