diff --git a/docs/changelog/103024.yaml b/docs/changelog/103024.yaml new file mode 100644 index 0000000000000..e860ad056f980 --- /dev/null +++ b/docs/changelog/103024.yaml @@ -0,0 +1,6 @@ +pr: 103024 +summary: Fix template simulate setting application ordering +area: Indices APIs +type: bug +issues: + - 103008 diff --git a/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadAnalyzerTests.java b/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadAnalyzerTests.java index 2ef1a7639e597..1014406745e1c 100644 --- a/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadAnalyzerTests.java +++ b/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadAnalyzerTests.java @@ -11,9 +11,9 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.AnalyzeToken; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.Response; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersRequest; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersResponse; +import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.index.mapper.MapperException; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.plugins.Plugin; @@ -121,7 +121,7 @@ private void updateSynonyms(Path synonymsFile, boolean preview) throws IOExcepti out.println("foo, baz, buzz"); } ReloadAnalyzersResponse reloadResponse = client().execute( - ReloadAnalyzerAction.INSTANCE, + TransportReloadAnalyzersAction.TYPE, new ReloadAnalyzersRequest(null, preview, INDEX_NAME) ).actionGet(); assertNoFailures(reloadResponse); @@ -183,7 +183,7 @@ public void testSynonymsInMultiplexerUpdateable() throws FileNotFoundException, out.println("foo, baz, buzz"); } ReloadAnalyzersResponse reloadResponse = client().execute( - ReloadAnalyzerAction.INSTANCE, + TransportReloadAnalyzersAction.TYPE, new ReloadAnalyzersRequest(null, false, INDEX_NAME) ).actionGet(); assertNoFailures(reloadResponse); @@ -303,7 +303,7 @@ public void testKeywordMarkerUpdateable() throws IOException { } ReloadAnalyzersResponse reloadResponse = client().execute( - ReloadAnalyzerAction.INSTANCE, + TransportReloadAnalyzersAction.TYPE, new ReloadAnalyzersRequest(null, false, INDEX_NAME) ).actionGet(); assertNoFailures(reloadResponse); diff --git a/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadSynonymAnalyzerIT.java b/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadSynonymAnalyzerIT.java index d55dbd0f1d783..e8164bfbb8f36 100644 --- a/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadSynonymAnalyzerIT.java +++ b/modules/analysis-common/src/internalClusterTest/java/org/elasticsearch/analysis/common/ReloadSynonymAnalyzerIT.java @@ -10,9 +10,9 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.AnalyzeToken; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.Response; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersRequest; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersResponse; +import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.env.Environment; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.plugins.Plugin; @@ -91,7 +91,7 @@ private void testSynonymsUpdate(boolean preview) throws FileNotFoundException, I out.println("foo, baz, " + testTerm); } ReloadAnalyzersResponse reloadResponse = client().execute( - ReloadAnalyzerAction.INSTANCE, + TransportReloadAnalyzersAction.TYPE, new ReloadAnalyzersRequest(null, preview, "test") ).actionGet(); assertNoFailures(reloadResponse); diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTests.java index 5fedb357fff8e..7fdce03252687 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTests.java @@ -21,9 +21,9 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshAction; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlocks; @@ -221,7 +221,7 @@ public void testIndexChunks() throws IOException { AtomicInteger chunkIndex = new AtomicInteger(); - client.addHandler(IndexAction.INSTANCE, (IndexRequest request, ActionListener listener) -> { + client.addHandler(TransportIndexAction.TYPE, (IndexRequest request, ActionListener listener) -> { int chunk = chunkIndex.getAndIncrement(); assertEquals(OpType.CREATE, request.opType()); assertThat(request.id(), Matchers.startsWith("test_" + (chunk + 15) + "_")); diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterHealthRestCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterHealthRestCancellationIT.java index 755bbce93c95b..f165f00c5cc2f 100644 --- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterHealthRestCancellationIT.java +++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterHealthRestCancellationIT.java @@ -9,7 +9,7 @@ package org.elasticsearch.http; import org.apache.http.client.methods.HttpGet; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Cancellable; import org.elasticsearch.client.Request; @@ -73,14 +73,14 @@ public void onFailure(Exception e) { safeAwait(barrier); - awaitTaskWithPrefixOnMaster(ClusterHealthAction.NAME); + awaitTaskWithPrefixOnMaster(TransportClusterHealthAction.NAME); logger.info("--> cancelling cluster health request"); cancellable.cancel(); expectThrows(CancellationException.class, future::actionGet); logger.info("--> checking cluster health task cancelled"); - assertAllCancellableTasksAreCancelled(ClusterHealthAction.NAME); + assertAllCancellableTasksAreCancelled(TransportClusterHealthAction.NAME); safeAwait(barrier); } diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java index d46868094907d..acfd870576b21 100644 --- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java +++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/RestActionCancellationIT.java @@ -10,7 +10,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.recovery.RecoveryAction; @@ -50,7 +50,7 @@ public void testCatRecoveryRestCancellation() { } public void testClusterHealthRestCancellation() { - runRestActionCancellationTest(new Request(HttpGet.METHOD_NAME, "/_cluster/health"), ClusterHealthAction.NAME); + runRestActionCancellationTest(new Request(HttpGet.METHOD_NAME, "/_cluster/health"), TransportClusterHealthAction.NAME); } public void testClusterStateRestCancellation() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java index 65438a442dc3b..f502525ef6346 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java @@ -12,8 +12,8 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheAction; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.flush.FlushRequest; @@ -47,12 +47,12 @@ import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.explain.ExplainRequest; import org.elasticsearch.action.explain.TransportExplainAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.get.GetRequest; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.MultiGetRequest; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchTransportService; @@ -62,7 +62,7 @@ import org.elasticsearch.action.termvectors.MultiTermVectorsRequest; import org.elasticsearch.action.termvectors.TermVectorsAction; import org.elasticsearch.action.termvectors.TermVectorsRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.internal.Requests; @@ -181,7 +181,7 @@ public void testGetFieldMappings() { } public void testFieldCapabilities() { - String fieldCapabilitiesShardAction = FieldCapabilitiesAction.NAME + "[n]"; + String fieldCapabilitiesShardAction = TransportFieldCapabilitiesAction.NAME + "[n]"; interceptTransportActions(fieldCapabilitiesShardAction); FieldCapabilitiesRequest fieldCapabilitiesRequest = new FieldCapabilitiesRequest(); @@ -229,7 +229,10 @@ public void testDelete() { public void testUpdate() { // update action goes to the primary, index op gets executed locally, then replicated - String[] updateShardActions = new String[] { UpdateAction.NAME + "[s]", BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" }; + String[] updateShardActions = new String[] { + TransportUpdateAction.NAME + "[s]", + BulkAction.NAME + "[s][p]", + BulkAction.NAME + "[s][r]" }; interceptTransportActions(updateShardActions); String indexOrAlias = randomIndexOrAlias(); @@ -244,7 +247,10 @@ public void testUpdate() { public void testUpdateUpsert() { // update action goes to the primary, index op gets executed locally, then replicated - String[] updateShardActions = new String[] { UpdateAction.NAME + "[s]", BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" }; + String[] updateShardActions = new String[] { + TransportUpdateAction.NAME + "[s]", + BulkAction.NAME + "[s][p]", + BulkAction.NAME + "[s][r]" }; interceptTransportActions(updateShardActions); String indexOrAlias = randomIndexOrAlias(); @@ -259,7 +265,10 @@ public void testUpdateUpsert() { public void testUpdateDelete() { // update action goes to the primary, delete op gets executed locally, then replicated - String[] updateShardActions = new String[] { UpdateAction.NAME + "[s]", BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]" }; + String[] updateShardActions = new String[] { + TransportUpdateAction.NAME + "[s]", + BulkAction.NAME + "[s][p]", + BulkAction.NAME + "[s][r]" }; interceptTransportActions(updateShardActions); String indexOrAlias = randomIndexOrAlias(); @@ -307,7 +316,7 @@ public void testBulk() { } public void testGet() { - String getShardAction = GetAction.NAME + "[s]"; + String getShardAction = TransportGetAction.TYPE.name() + "[s]"; interceptTransportActions(getShardAction); GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "id"); @@ -358,7 +367,7 @@ public void testMultiTermVector() { } public void testMultiGet() { - String multiGetShardAction = MultiGetAction.NAME + "[shard][s]"; + String multiGetShardAction = TransportMultiGetAction.NAME + "[shard][s]"; interceptTransportActions(multiGetShardAction); List indicesOrAliases = new ArrayList<>(); @@ -484,13 +493,13 @@ public void testOpenIndex() { } public void testCloseIndex() { - interceptTransportActions(CloseIndexAction.NAME); + interceptTransportActions(TransportCloseIndexAction.NAME); CloseIndexRequest closeIndexRequest = new CloseIndexRequest(randomUniqueIndicesOrAliases()); internalCluster().coordOnlyNodeClient().admin().indices().close(closeIndexRequest).actionGet(); clearInterceptedActions(); - assertSameIndices(closeIndexRequest, CloseIndexAction.NAME); + assertSameIndices(closeIndexRequest, TransportCloseIndexAction.NAME); } public void testDeleteIndex() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java index f598f7bad12f2..f6dcb07e04890 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java @@ -15,7 +15,7 @@ import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.TaskOperationFailure; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskRequest; import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskResponse; @@ -26,7 +26,7 @@ import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryAction; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequestBuilder; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchTransportService; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.WriteRequest; @@ -137,24 +137,24 @@ public void testTaskCounts() { } public void testMasterNodeOperationTasks() throws Exception { - registerTaskManagerListeners(ClusterHealthAction.NAME); + registerTaskManagerListeners(TransportClusterHealthAction.NAME); // First run the health on the master node - should produce only one task on the master node internalCluster().masterClient().admin().cluster().prepareHealth().get(); - assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events + assertEquals(1, numberOfEvents(TransportClusterHealthAction.NAME, Tuple::v1)); // counting only registration events // counting only unregistration events // When checking unregistration events there might be some delay since receiving the response from the cluster doesn't // guarantee that the task has been unregistered. - assertBusy(() -> assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false))); + assertBusy(() -> assertEquals(1, numberOfEvents(TransportClusterHealthAction.NAME, event -> event.v1() == false))); - resetTaskManagerListeners(ClusterHealthAction.NAME); + resetTaskManagerListeners(TransportClusterHealthAction.NAME); // Now run the health on a non-master node - should produce one task on master and one task on another node internalCluster().nonMasterClient().admin().cluster().prepareHealth().get(); - assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events + assertEquals(2, numberOfEvents(TransportClusterHealthAction.NAME, Tuple::v1)); // counting only registration events // counting only unregistration events - assertBusy(() -> assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false))); - List tasks = findEvents(ClusterHealthAction.NAME, Tuple::v1); + assertBusy(() -> assertEquals(2, numberOfEvents(TransportClusterHealthAction.NAME, event -> event.v1() == false))); + List tasks = findEvents(TransportClusterHealthAction.NAME, Tuple::v1); // Verify that one of these tasks is a parent of another task if (tasks.get(0).parentTaskId().isSet()) { @@ -436,7 +436,7 @@ public void testCanFetchIndexStatus() throws Exception { ((MockTaskManager) transportService.getTaskManager()).addListener(new MockTaskManagerListener() { @Override public void onTaskRegistered(Task task) { - if (task.getAction().startsWith(IndexAction.NAME)) { + if (task.getAction().startsWith(TransportIndexAction.NAME)) { taskRegistered.countDown(); logger.debug("Blocking [{}] starting", task); try { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java index 02867e0cf6920..6139d6875d5ae 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -14,7 +14,6 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesFailure; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; @@ -478,7 +477,7 @@ public void testTargetNodeFails() throws Exception { if (randomBoolean()) { request.indexFilter(QueryBuilders.rangeQuery("timestamp").gte("2020-01-01")); } - final FieldCapabilitiesResponse response = client().execute(FieldCapabilitiesAction.INSTANCE, request).actionGet(); + final FieldCapabilitiesResponse response = client().execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet(); assertTrue(failedRequest.get()); assertThat(response.getIndices(), arrayContainingInAnyOrder("log-index-1", "log-index-2")); assertThat(response.getField("field1"), aMapWithSize(2)); @@ -512,7 +511,7 @@ public void testNoActiveCopy() throws Exception { if (randomBoolean()) { request.indexFilter(QueryBuilders.rangeQuery("timestamp").gte("2020-01-01")); } - final FieldCapabilitiesResponse response = client().execute(FieldCapabilitiesAction.INSTANCE, request).actionGet(); + final FieldCapabilitiesResponse response = client().execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet(); assertThat(response.getIndices(), arrayContainingInAnyOrder("log-index-1", "log-index-2")); assertThat(response.getField("field1"), aMapWithSize(2)); assertThat(response.getField("field1"), hasKey("long")); @@ -574,7 +573,7 @@ public void testRelocation() throws Exception { if (randomBoolean()) { request.indexFilter(QueryBuilders.rangeQuery("timestamp").gte("2020-01-01")); } - final FieldCapabilitiesResponse response = client().execute(FieldCapabilitiesAction.INSTANCE, request).actionGet(); + final FieldCapabilitiesResponse response = client().execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet(); assertThat(response.getIndices(), arrayContainingInAnyOrder("log-index-1", "log-index-2")); assertThat(response.getField("field1"), aMapWithSize(2)); assertThat(response.getField("field1"), hasKey("long")); @@ -630,7 +629,7 @@ public void testManyIndicesWithSameMapping() { } }; // Single mapping - verifyResponse.accept(client().execute(FieldCapabilitiesAction.INSTANCE, request).actionGet()); + verifyResponse.accept(client().execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet()); // add an extra field for some indices String[] indicesWithExtraField = randomSubsetOf(between(1, indices.length), indices).stream().sorted().toArray(String[]::new); @@ -639,7 +638,7 @@ public void testManyIndicesWithSameMapping() { for (String index : indicesWithExtraField) { prepareIndex(index).setSource("extra_field", randomIntBetween(1, 1000)).get(); } - FieldCapabilitiesResponse resp = client().execute(FieldCapabilitiesAction.INSTANCE, request).actionGet(); + FieldCapabilitiesResponse resp = client().execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet(); verifyResponse.accept(resp); assertThat(resp.getField("extra_field"), hasKey("integer")); assertThat(resp.getField("extra_field").get("integer").indices(), nullValue()); diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index 8e008dc57c81b..01e51d47722f6 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -29,7 +29,6 @@ import org.elasticsearch.action.admin.cluster.desirednodes.TransportGetDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.TransportUpdateDesiredNodesAction; import org.elasticsearch.action.admin.cluster.desirednodes.UpdateDesiredNodesAction; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction; @@ -102,20 +101,16 @@ import org.elasticsearch.action.admin.cluster.storedscripts.TransportGetScriptLanguageAction; import org.elasticsearch.action.admin.cluster.storedscripts.TransportGetStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.TransportPutStoredScriptAction; -import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksAction; import org.elasticsearch.action.admin.cluster.tasks.TransportPendingClusterTasksAction; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.TransportGetAliasesAction; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; import org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction; import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheAction; import org.elasticsearch.action.admin.indices.cache.clear.TransportClearIndicesCacheAction; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.close.TransportVerifyShardBeforeCloseAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; @@ -206,17 +201,12 @@ import org.elasticsearch.action.bulk.TransportBulkAction; import org.elasticsearch.action.bulk.TransportShardBulkAction; import org.elasticsearch.action.bulk.TransportSimulateBulkAction; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.explain.TransportExplainAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; -import org.elasticsearch.action.get.GetAction; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.get.TransportShardMultiGetAction; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.ingest.DeletePipelineAction; import org.elasticsearch.action.ingest.DeletePipelineTransportAction; @@ -262,7 +252,6 @@ import org.elasticsearch.action.termvectors.TransportShardMultiTermsVectorAction; import org.elasticsearch.action.termvectors.TransportTermVectorsAction; import org.elasticsearch.action.update.TransportUpdateAction; -import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -682,13 +671,13 @@ public void reg actions.register(DeleteDesiredBalanceAction.INSTANCE, TransportDeleteDesiredBalanceAction.class); actions.register(ClusterStatsAction.INSTANCE, TransportClusterStatsAction.class); actions.register(ClusterStateAction.INSTANCE, TransportClusterStateAction.class); - actions.register(ClusterHealthAction.INSTANCE, TransportClusterHealthAction.class); + actions.register(TransportClusterHealthAction.TYPE, TransportClusterHealthAction.class); actions.register(ClusterUpdateSettingsAction.INSTANCE, TransportClusterUpdateSettingsAction.class); actions.register(ClusterGetSettingsAction.INSTANCE, TransportClusterGetSettingsAction.class); actions.register(ClusterRerouteAction.INSTANCE, TransportClusterRerouteAction.class); actions.register(ClusterSearchShardsAction.INSTANCE, TransportClusterSearchShardsAction.class); actions.register(ClusterFormationInfoAction.INSTANCE, ClusterFormationInfoAction.TransportAction.class); - actions.register(PendingClusterTasksAction.INSTANCE, TransportPendingClusterTasksAction.class); + actions.register(TransportPendingClusterTasksAction.TYPE, TransportPendingClusterTasksAction.class); actions.register(PutRepositoryAction.INSTANCE, TransportPutRepositoryAction.class); actions.register(GetRepositoriesAction.INSTANCE, TransportGetRepositoriesAction.class); actions.register(DeleteRepositoryAction.INSTANCE, TransportDeleteRepositoryAction.class); @@ -715,17 +704,17 @@ public void reg actions.register(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class); actions.register(GetIndexAction.INSTANCE, TransportGetIndexAction.class); actions.register(OpenIndexAction.INSTANCE, TransportOpenIndexAction.class); - actions.register(CloseIndexAction.INSTANCE, TransportCloseIndexAction.class); + actions.register(TransportCloseIndexAction.TYPE, TransportCloseIndexAction.class); actions.register(AddIndexBlockAction.INSTANCE, TransportAddIndexBlockAction.class); actions.register(GetMappingsAction.INSTANCE, TransportGetMappingsAction.class); actions.register(GetFieldMappingsAction.INSTANCE, TransportGetFieldMappingsAction.class); actions.register(TransportGetFieldMappingsIndexAction.TYPE, TransportGetFieldMappingsIndexAction.class); actions.register(PutMappingAction.INSTANCE, TransportPutMappingAction.class); actions.register(AutoPutMappingAction.INSTANCE, TransportAutoPutMappingAction.class); - actions.register(IndicesAliasesAction.INSTANCE, TransportIndicesAliasesAction.class); + actions.register(TransportIndicesAliasesAction.TYPE, TransportIndicesAliasesAction.class); actions.register(UpdateSettingsAction.INSTANCE, TransportUpdateSettingsAction.class); actions.register(AnalyzeAction.INSTANCE, TransportAnalyzeAction.class); - actions.register(ReloadAnalyzerAction.INSTANCE, TransportReloadAnalyzersAction.class); + actions.register(TransportReloadAnalyzersAction.TYPE, TransportReloadAnalyzersAction.class); actions.register(PutIndexTemplateAction.INSTANCE, TransportPutIndexTemplateAction.class); actions.register(GetIndexTemplatesAction.INSTANCE, TransportGetIndexTemplatesAction.class); actions.register(DeleteIndexTemplateAction.INSTANCE, TransportDeleteIndexTemplateAction.class); @@ -745,14 +734,14 @@ public void reg actions.register(GetAliasesAction.INSTANCE, TransportGetAliasesAction.class); actions.register(GetSettingsAction.INSTANCE, TransportGetSettingsAction.class); - actions.register(IndexAction.INSTANCE, TransportIndexAction.class); - actions.register(GetAction.INSTANCE, TransportGetAction.class); + actions.register(TransportIndexAction.TYPE, TransportIndexAction.class); + actions.register(TransportGetAction.TYPE, TransportGetAction.class); actions.register(TermVectorsAction.INSTANCE, TransportTermVectorsAction.class); actions.register(MultiTermVectorsAction.INSTANCE, TransportMultiTermVectorsAction.class); actions.register(TransportShardMultiTermsVectorAction.TYPE, TransportShardMultiTermsVectorAction.class); - actions.register(DeleteAction.INSTANCE, TransportDeleteAction.class); - actions.register(UpdateAction.INSTANCE, TransportUpdateAction.class); - actions.register(MultiGetAction.INSTANCE, TransportMultiGetAction.class); + actions.register(TransportDeleteAction.TYPE, TransportDeleteAction.class); + actions.register(TransportUpdateAction.TYPE, TransportUpdateAction.class); + actions.register(TransportMultiGetAction.TYPE, TransportMultiGetAction.class); actions.register(TransportShardMultiGetAction.TYPE, TransportShardMultiGetAction.class); actions.register(BulkAction.INSTANCE, TransportBulkAction.class); actions.register(SimulateBulkAction.INSTANCE, TransportSimulateBulkAction.class); @@ -781,7 +770,7 @@ public void reg actions.register(GetScriptContextAction.INSTANCE, TransportGetScriptContextAction.class); actions.register(GetScriptLanguageAction.INSTANCE, TransportGetScriptLanguageAction.class); - actions.register(FieldCapabilitiesAction.INSTANCE, TransportFieldCapabilitiesAction.class); + actions.register(TransportFieldCapabilitiesAction.TYPE, TransportFieldCapabilitiesAction.class); actions.register(PutPipelineAction.INSTANCE, PutPipelineTransportAction.class); actions.register(GetPipelineAction.INSTANCE, GetPipelineTransportAction.class); diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java index b6e5a51c117b7..230a8154b64ce 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java @@ -131,7 +131,7 @@ protected DocWriteResponse(ShardId shardId, StreamInput in) throws IOException { } /** - * Needed for deserialization of single item requests in {@link org.elasticsearch.action.index.IndexAction} and BwC + * Needed for deserialization of single item requests in {@link org.elasticsearch.action.index.TransportIndexAction} and BwC * deserialization path */ protected DocWriteResponse(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthAction.java deleted file mode 100644 index 369c11a7e6290..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.admin.cluster.health; - -import org.elasticsearch.action.ActionType; - -public class ClusterHealthAction extends ActionType { - - public static final ClusterHealthAction INSTANCE = new ClusterHealthAction(); - public static final String NAME = "cluster:monitor/health"; - - private ClusterHealthAction() { - super(NAME, ClusterHealthResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java index e69c8862a4885..cfd1fd71b612e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java @@ -22,7 +22,7 @@ public class ClusterHealthRequestBuilder extends MasterNodeReadOperationRequestB ClusterHealthRequestBuilder> { public ClusterHealthRequestBuilder(ElasticsearchClient client) { - super(client, ClusterHealthAction.INSTANCE, new ClusterHealthRequest()); + super(client, TransportClusterHealthAction.TYPE, new ClusterHealthRequest()); } public ClusterHealthRequestBuilder setIndices(String... indices) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java index 935cc15eefe51..5af2d546ac624 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -12,6 +12,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.IndicesOptions; @@ -47,6 +48,8 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction { + public static final String NAME = "cluster:monitor/health"; + public static final ActionType TYPE = new ActionType(NAME, ClusterHealthResponse::new); private static final Logger logger = LogManager.getLogger(TransportClusterHealthAction.class); private final AllocationService allocationService; @@ -61,7 +64,7 @@ public TransportClusterHealthAction( AllocationService allocationService ) { super( - ClusterHealthAction.NAME, + NAME, false, transportService, clusterService, @@ -157,6 +160,7 @@ public void onFailure(Exception e) { } else { final TimeValue taskTimeout = TimeValue.timeValueMillis(Math.max(0, endTimeRelativeMillis - threadPool.relativeTimeInMillis())); submitUnbatchedTask(source, new ClusterStateUpdateTask(request.waitForEvents(), taskTimeout) { + @Override public ClusterState execute(ClusterState currentState) { return currentState; @@ -207,6 +211,7 @@ static boolean isExpectedFailure(Exception e) { && e.getCause() instanceof EsRejectedExecutionException esre && esre.isExecutorShutdown(); } + }); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksAction.java deleted file mode 100644 index ee76bd89fce3c..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.admin.cluster.tasks; - -import org.elasticsearch.action.ActionType; - -public class PendingClusterTasksAction extends ActionType { - - public static final PendingClusterTasksAction INSTANCE = new PendingClusterTasksAction(); - public static final String NAME = "cluster:monitor/task"; - - private PendingClusterTasksAction() { - super(NAME, PendingClusterTasksResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequestBuilder.java index 4de6d262a06e2..aa3f226d23c9d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequestBuilder.java @@ -17,6 +17,6 @@ public class PendingClusterTasksRequestBuilder extends MasterNodeReadOperationRe PendingClusterTasksRequestBuilder> { public PendingClusterTasksRequestBuilder(ElasticsearchClient client) { - super(client, PendingClusterTasksAction.INSTANCE, new PendingClusterTasksRequest()); + super(client, TransportPendingClusterTasksAction.TYPE, new PendingClusterTasksRequest()); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java index ba7e799095ef8..a03f0d36f7dad 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.cluster.ClusterState; @@ -30,6 +31,10 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadA PendingClusterTasksRequest, PendingClusterTasksResponse> { + public static final ActionType TYPE = new ActionType<>( + "cluster:monitor/task", + PendingClusterTasksResponse::new + ); private static final Logger logger = LogManager.getLogger(TransportPendingClusterTasksAction.class); private final ClusterService clusterService; @@ -43,7 +48,7 @@ public TransportPendingClusterTasksAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - PendingClusterTasksAction.NAME, + TYPE.name(), transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java deleted file mode 100644 index 6c3a5ec3eabc6..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.admin.indices.alias; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.master.AcknowledgedResponse; - -public class IndicesAliasesAction extends ActionType { - - public static final IndicesAliasesAction INSTANCE = new IndicesAliasesAction(); - public static final String NAME = "indices:admin/aliases"; - - private IndicesAliasesAction() { - super(NAME, AcknowledgedResponse::readFrom); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequestBuilder.java index 47aaf53bd1c98..4e49a5fe8d400 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequestBuilder.java @@ -25,7 +25,7 @@ public class IndicesAliasesRequestBuilder extends AcknowledgedRequestBuilder< IndicesAliasesRequestBuilder> { public IndicesAliasesRequestBuilder(ElasticsearchClient client) { - super(client, IndicesAliasesAction.INSTANCE, new IndicesAliasesRequest()); + super(client, TransportIndicesAliasesAction.TYPE, new IndicesAliasesRequest()); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index fd3a200075d75..66a489933c3ee 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.RequestValidators; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.elasticsearch.action.support.ActionFilters; @@ -57,6 +58,8 @@ */ public class TransportIndicesAliasesAction extends AcknowledgedTransportMasterNodeAction { + public static final String NAME = "indices:admin/aliases"; + public static final ActionType TYPE = new ActionType<>(NAME, AcknowledgedResponse::readFrom); private static final Logger logger = LogManager.getLogger(TransportIndicesAliasesAction.class); private final MetadataIndexAliasesService indexAliasesService; @@ -75,7 +78,7 @@ public TransportIndicesAliasesAction( final SystemIndices systemIndices ) { super( - IndicesAliasesAction.NAME, + NAME, transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzerAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzerAction.java deleted file mode 100644 index fb96ee1860392..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzerAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.admin.indices.analyze; - -import org.elasticsearch.action.ActionType; - -public class ReloadAnalyzerAction extends ActionType { - - public static final ReloadAnalyzerAction INSTANCE = new ReloadAnalyzerAction(); - public static final String NAME = "indices:admin/reload_analyzers"; - - private ReloadAnalyzerAction() { - super(NAME, ReloadAnalyzersResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportReloadAnalyzersAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportReloadAnalyzersAction.java index 01e02b46b9cb7..2930d578a7b2f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportReloadAnalyzersAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportReloadAnalyzersAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -50,6 +51,10 @@ public class TransportReloadAnalyzersAction extends TransportBroadcastByNodeActi ReloadAnalyzersResponse, TransportReloadAnalyzersAction.ReloadResult> { + public static final ActionType TYPE = new ActionType<>( + "indices:admin/reload_analyzers", + ReloadAnalyzersResponse::new + ); private static final Logger logger = LogManager.getLogger(TransportReloadAnalyzersAction.class); private final IndicesService indicesService; @@ -62,7 +67,7 @@ public TransportReloadAnalyzersAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - ReloadAnalyzerAction.NAME, + TYPE.name(), clusterService, transportService, actionFilters, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java deleted file mode 100644 index 02afb59081131..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.admin.indices.close; - -import org.elasticsearch.action.ActionType; - -public class CloseIndexAction extends ActionType { - - public static final CloseIndexAction INSTANCE = new CloseIndexAction(); - public static final String NAME = "indices:admin/close"; - - private CloseIndexAction() { - super(NAME, CloseIndexResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestBuilder.java index 0a9d7fb1bcf7a..0b19a9f6eb69a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestBuilder.java @@ -19,7 +19,7 @@ public class CloseIndexRequestBuilder extends AcknowledgedRequestBuilder { public CloseIndexRequestBuilder(ElasticsearchClient client, String... indices) { - super(client, CloseIndexAction.INSTANCE, new CloseIndexRequest(indices)); + super(client, TransportCloseIndexAction.TYPE, new CloseIndexRequest(indices)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java index 0103e8abf654a..f4a65a2b6490f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.master.TransportMasterNodeAction; @@ -39,6 +40,8 @@ */ public class TransportCloseIndexAction extends TransportMasterNodeAction { + public static final String NAME = "indices:admin/close"; + public static final ActionType TYPE = new ActionType<>(NAME, CloseIndexResponse::new); private static final Logger logger = LogManager.getLogger(TransportCloseIndexAction.class); private final MetadataIndexStateService indexStateService; @@ -64,7 +67,7 @@ public TransportCloseIndexAction( DestructiveOperations destructiveOperations ) { super( - CloseIndexAction.NAME, + NAME, transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java index c8ecbf273c93c..c5b5602a963d4 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java @@ -41,7 +41,7 @@ public class TransportVerifyShardBeforeCloseAction extends TransportReplicationA TransportVerifyShardBeforeCloseAction.ShardRequest, ReplicationResponse> { - public static final String NAME = CloseIndexAction.NAME + "[s]"; + public static final String NAME = TransportCloseIndexAction.NAME + "[s]"; public static final ActionType TYPE = new ActionType<>(NAME, ReplicationResponse::new); private static final Logger logger = LogManager.getLogger(TransportVerifyShardBeforeCloseAction.class); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java index af40637db6703..bee6ab7f78be0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java @@ -307,7 +307,7 @@ public static Template resolveTemplate( } ); - Settings settings = Settings.builder().put(templateSettings).put(additionalSettings.build()).build(); + Settings settings = Settings.builder().put(additionalSettings.build()).put(templateSettings).build(); DataStreamLifecycle lifecycle = resolveLifecycle(simulatedState.metadata(), matchingTemplate); if (template.getDataStreamTemplate() != null && lifecycle == null && isDslOnlyMode) { lifecycle = DataStreamLifecycle.DEFAULT; diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteAction.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteAction.java deleted file mode 100644 index 9a16cb8dd4eec..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.delete; - -import org.elasticsearch.action.ActionType; - -public class DeleteAction extends ActionType { - - public static final DeleteAction INSTANCE = new DeleteAction(); - public static final String NAME = "indices:data/write/delete"; - - private DeleteAction() { - super(NAME, DeleteResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java index 7107073b6b738..f99bea1a64821 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java @@ -22,7 +22,7 @@ public class DeleteRequestBuilder extends ReplicationRequestBuilder { public DeleteRequestBuilder(ElasticsearchClient client, @Nullable String index) { - super(client, DeleteAction.INSTANCE, new DeleteRequest(index)); + super(client, TransportDeleteAction.TYPE, new DeleteRequest(index)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java b/server/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java index 0b6824a1c7c49..6c275d994a4ed 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java +++ b/server/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java @@ -8,6 +8,7 @@ package org.elasticsearch.action.delete; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.bulk.TransportBulkAction; import org.elasticsearch.action.bulk.TransportSingleItemBulkWriteAction; import org.elasticsearch.action.support.ActionFilters; @@ -22,8 +23,11 @@ @Deprecated public class TransportDeleteAction extends TransportSingleItemBulkWriteAction { + public static final String NAME = "indices:data/write/delete"; + public static final ActionType TYPE = new ActionType<>(NAME, DeleteResponse::new); + @Inject public TransportDeleteAction(TransportService transportService, ActionFilters actionFilters, TransportBulkAction bulkAction) { - super(DeleteAction.NAME, transportService, actionFilters, DeleteRequest::new, bulkAction); + super(NAME, transportService, actionFilters, DeleteRequest::new, bulkAction); } } diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesAction.java deleted file mode 100644 index eb63f844f49bf..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.fieldcaps; - -import org.elasticsearch.action.ActionType; - -public class FieldCapabilitiesAction extends ActionType { - - public static final FieldCapabilitiesAction INSTANCE = new FieldCapabilitiesAction(); - public static final String NAME = "indices:data/read/field_caps"; - - private FieldCapabilitiesAction() { - super(NAME, FieldCapabilitiesResponse::new); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestBuilder.java index 892a08c837949..511988cf561b9 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestBuilder.java @@ -16,7 +16,7 @@ public class FieldCapabilitiesRequestBuilder extends ActionRequestBuilder { public FieldCapabilitiesRequestBuilder(ElasticsearchClient client, String... indices) { - super(client, FieldCapabilitiesAction.INSTANCE, new FieldCapabilitiesRequest().indices(indices)); + super(client, TransportFieldCapabilitiesAction.TYPE, new FieldCapabilitiesRequest().indices(indices)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java index d9837f94b0996..2e3dd1ab443f9 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java @@ -12,6 +12,7 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRunnable; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.OriginalIndices; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ChannelActionListener; @@ -63,7 +64,9 @@ import static org.elasticsearch.action.search.TransportSearchHelper.checkCCSVersionCompatibility; public class TransportFieldCapabilitiesAction extends HandledTransportAction { - public static final String ACTION_NODE_NAME = FieldCapabilitiesAction.NAME + "[n]"; + public static final String NAME = "indices:data/read/field_caps"; + public static final ActionType TYPE = new ActionType<>(NAME, FieldCapabilitiesResponse::new); + public static final String ACTION_NODE_NAME = NAME + "[n]"; public static final Logger LOGGER = LogManager.getLogger(TransportFieldCapabilitiesAction.class); private final ThreadPool threadPool; @@ -86,7 +89,7 @@ public TransportFieldCapabilitiesAction( ) { // TODO replace SAME when removing workaround for https://github.com/elastic/elasticsearch/issues/97916 super( - FieldCapabilitiesAction.NAME, + NAME, transportService, actionFilters, FieldCapabilitiesRequest::new, diff --git a/server/src/main/java/org/elasticsearch/action/get/GetAction.java b/server/src/main/java/org/elasticsearch/action/get/GetAction.java deleted file mode 100644 index 7e4dbca6d46d7..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/get/GetAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.get; - -import org.elasticsearch.action.ActionType; - -public class GetAction extends ActionType { - - public static final GetAction INSTANCE = new GetAction(); - public static final String NAME = "indices:data/read/get"; - - private GetAction() { - super(NAME, GetResponse::new); - } - -} diff --git a/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java index f9e748a6e2b22..d581bfa73a1f5 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java @@ -21,11 +21,11 @@ public class GetRequestBuilder extends SingleShardOperationRequestBuilder { public GetRequestBuilder(ElasticsearchClient client) { - super(client, GetAction.INSTANCE, new GetRequest()); + super(client, TransportGetAction.TYPE, new GetRequest()); } public GetRequestBuilder(ElasticsearchClient client, @Nullable String index) { - super(client, GetAction.INSTANCE, new GetRequest(index)); + super(client, TransportGetAction.TYPE, new GetRequest(index)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetAction.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetAction.java deleted file mode 100644 index 15dbdcee57428..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.get; - -import org.elasticsearch.action.ActionType; - -public class MultiGetAction extends ActionType { - - public static final MultiGetAction INSTANCE = new MultiGetAction(); - public static final String NAME = "indices:data/read/mget"; - - private MultiGetAction() { - super(NAME, MultiGetResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java index f872406dbeda2..8512ae959cb52 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java @@ -17,7 +17,7 @@ public class MultiGetRequestBuilder extends ActionRequestBuilder { public MultiGetRequestBuilder(ElasticsearchClient client) { - super(client, MultiGetAction.INSTANCE, new MultiGetRequest()); + super(client, TransportMultiGetAction.TYPE, new MultiGetRequest()); } public MultiGetRequestBuilder add(String index, String id) { diff --git a/server/src/main/java/org/elasticsearch/action/get/TransportGetAction.java b/server/src/main/java/org/elasticsearch/action/get/TransportGetAction.java index 9f2fe8ae5aa8c..6440304360bf3 100644 --- a/server/src/main/java/org/elasticsearch/action/get/TransportGetAction.java +++ b/server/src/main/java/org/elasticsearch/action/get/TransportGetAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListenerResponseHandler; import org.elasticsearch.action.ActionRunnable; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.NoShardAvailableActionException; import org.elasticsearch.action.admin.indices.refresh.TransportShardRefreshAction; import org.elasticsearch.action.support.ActionFilters; @@ -46,6 +47,7 @@ */ public class TransportGetAction extends TransportSingleShardAction { + public static final ActionType TYPE = new ActionType<>("indices:data/read/get", GetResponse::new); private static final Logger logger = LogManager.getLogger(TransportGetAction.class); private final IndicesService indicesService; @@ -64,7 +66,7 @@ public TransportGetAction( NodeClient client ) { super( - GetAction.NAME, + TYPE.name(), threadPool, clusterService, transportService, diff --git a/server/src/main/java/org/elasticsearch/action/get/TransportMultiGetAction.java b/server/src/main/java/org/elasticsearch/action/get/TransportMultiGetAction.java index 8669524504879..7db644415dbc2 100644 --- a/server/src/main/java/org/elasticsearch/action/get/TransportMultiGetAction.java +++ b/server/src/main/java/org/elasticsearch/action/get/TransportMultiGetAction.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.get; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.support.ActionFilters; @@ -33,6 +34,8 @@ public class TransportMultiGetAction extends HandledTransportAction { + public static final String NAME = "indices:data/read/mget"; + public static final ActionType TYPE = new ActionType<>(NAME, MultiGetResponse::new); private final ClusterService clusterService; private final NodeClient client; private final IndexNameExpressionResolver indexNameExpressionResolver; @@ -46,7 +49,7 @@ public TransportMultiGetAction( IndexNameExpressionResolver resolver, IndicesService indicesService ) { - super(MultiGetAction.NAME, transportService, actionFilters, MultiGetRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); + super(NAME, transportService, actionFilters, MultiGetRequest::new, EsExecutors.DIRECT_EXECUTOR_SERVICE); this.clusterService = clusterService; this.client = client; this.indexNameExpressionResolver = resolver; diff --git a/server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java b/server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java index 9986c4019c81b..a05bbf1bfd9d3 100644 --- a/server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java +++ b/server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java @@ -47,7 +47,7 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction { - private static final String ACTION_NAME = MultiGetAction.NAME + "[shard]"; + private static final String ACTION_NAME = TransportMultiGetAction.NAME + "[shard]"; public static final ActionType TYPE = new ActionType<>(ACTION_NAME, MultiGetShardResponse::new); private static final Logger logger = LogManager.getLogger(TransportShardMultiGetAction.class); diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexAction.java b/server/src/main/java/org/elasticsearch/action/index/IndexAction.java deleted file mode 100644 index 3cb01be92e734..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/index/IndexAction.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.index; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.DocWriteResponse; - -public class IndexAction extends ActionType { - - public static final IndexAction INSTANCE = new IndexAction(); - public static final String NAME = "indices:data/write/index"; - - private IndexAction() { - super(NAME, in -> { - assert false : "Might not be an IndexResponse!"; - return new IndexResponse(in); - }); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java index 4cc26f056245a..5e156070d0154 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java @@ -29,11 +29,11 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder { public IndexRequestBuilder(ElasticsearchClient client) { - super(client, IndexAction.INSTANCE, new IndexRequest()); + super(client, TransportIndexAction.TYPE, new IndexRequest()); } public IndexRequestBuilder(ElasticsearchClient client, @Nullable String index) { - super(client, IndexAction.INSTANCE, new IndexRequest(index)); + super(client, TransportIndexAction.TYPE, new IndexRequest(index)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/server/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java index 6c75374d51012..5e91498244dd0 100644 --- a/server/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java @@ -8,6 +8,7 @@ package org.elasticsearch.action.index; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.bulk.TransportBulkAction; import org.elasticsearch.action.bulk.TransportSingleItemBulkWriteAction; @@ -30,8 +31,14 @@ @Deprecated public class TransportIndexAction extends TransportSingleItemBulkWriteAction { + public static final String NAME = "indices:data/write/index"; + public static final ActionType TYPE = new ActionType<>(NAME, in -> { + assert false : "Might not be an IndexResponse!"; + return new IndexResponse(in); + }); + @Inject public TransportIndexAction(ActionFilters actionFilters, TransportService transportService, TransportBulkAction bulkAction) { - super(IndexAction.NAME, transportService, actionFilters, IndexRequest::new, bulkAction); + super(NAME, transportService, actionFilters, IndexRequest::new, bulkAction); } } diff --git a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 2510d1c5a8c2e..c73679a2527df 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRunnable; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; @@ -59,6 +60,8 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationAction { + public static final String NAME = "indices:data/write/update"; + public static final ActionType TYPE = new ActionType<>(NAME, UpdateResponse::new); private final AutoCreateIndex autoCreateIndex; private final UpdateHelper updateHelper; private final IndicesService indicesService; @@ -77,15 +80,7 @@ public TransportUpdateAction( AutoCreateIndex autoCreateIndex, NodeClient client ) { - super( - UpdateAction.NAME, - threadPool, - clusterService, - transportService, - actionFilters, - indexNameExpressionResolver, - UpdateRequest::new - ); + super(NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, UpdateRequest::new); this.updateHelper = updateHelper; this.indicesService = indicesService; this.autoCreateIndex = autoCreateIndex; diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/UpdateAction.java deleted file mode 100644 index d99aa172169c7..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.update; - -import org.elasticsearch.action.ActionType; - -public class UpdateAction extends ActionType { - - public static final UpdateAction INSTANCE = new UpdateAction(); - public static final String NAME = "indices:data/write/update"; - - private UpdateAction() { - super(NAME, UpdateResponse::new); - } -} diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java index 6b7d79abc51a3..c7bd513ff84d4 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java @@ -27,11 +27,11 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder { public UpdateRequestBuilder(ElasticsearchClient client) { - super(client, UpdateAction.INSTANCE, new UpdateRequest()); + super(client, TransportUpdateAction.TYPE, new UpdateRequest()); } public UpdateRequestBuilder(ElasticsearchClient client, String index, String id) { - super(client, UpdateAction.INSTANCE, new UpdateRequest(index, id)); + super(client, TransportUpdateAction.TYPE, new UpdateRequest(index, id)); } /** diff --git a/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java index d5fa2f7796252..182e9ee497c07 100644 --- a/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/internal/support/AbstractClient.java @@ -20,10 +20,10 @@ import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequestBuilder; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequestBuilder; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse; @@ -122,13 +122,13 @@ import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptAction; import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequestBuilder; -import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksAction; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequestBuilder; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; +import org.elasticsearch.action.admin.cluster.tasks.TransportPendingClusterTasksAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder; @@ -139,10 +139,10 @@ import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequestBuilder; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.close.CloseIndexRequestBuilder; import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; @@ -242,29 +242,29 @@ import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteRequestBuilder; import org.elasticsearch.action.delete.DeleteResponse; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.explain.ExplainRequest; import org.elasticsearch.action.explain.ExplainRequestBuilder; import org.elasticsearch.action.explain.ExplainResponse; import org.elasticsearch.action.explain.TransportExplainAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequestBuilder; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.ingest.DeletePipelineAction; import org.elasticsearch.action.ingest.DeletePipelineRequest; import org.elasticsearch.action.ingest.DeletePipelineRequestBuilder; @@ -304,7 +304,7 @@ import org.elasticsearch.action.termvectors.TermVectorsRequest; import org.elasticsearch.action.termvectors.TermVectorsRequestBuilder; import org.elasticsearch.action.termvectors.TermVectorsResponse; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.action.update.UpdateResponse; @@ -393,12 +393,12 @@ protected abstract index(final IndexRequest request) { - return execute(IndexAction.INSTANCE, request); + return execute(TransportIndexAction.TYPE, request); } @Override public void index(final IndexRequest request, final ActionListener listener) { - execute(IndexAction.INSTANCE, request, listener); + execute(TransportIndexAction.TYPE, request, listener); } @Override @@ -413,12 +413,12 @@ public IndexRequestBuilder prepareIndex(String index) { @Override public ActionFuture update(final UpdateRequest request) { - return execute(UpdateAction.INSTANCE, request); + return execute(TransportUpdateAction.TYPE, request); } @Override public void update(final UpdateRequest request, final ActionListener listener) { - execute(UpdateAction.INSTANCE, request, listener); + execute(TransportUpdateAction.TYPE, request, listener); } @Override @@ -433,12 +433,12 @@ public UpdateRequestBuilder prepareUpdate(String index, String id) { @Override public ActionFuture delete(final DeleteRequest request) { - return execute(DeleteAction.INSTANCE, request); + return execute(TransportDeleteAction.TYPE, request); } @Override public void delete(final DeleteRequest request, final ActionListener listener) { - execute(DeleteAction.INSTANCE, request, listener); + execute(TransportDeleteAction.TYPE, request, listener); } @Override @@ -473,12 +473,12 @@ public BulkRequestBuilder prepareBulk(@Nullable String globalIndex) { @Override public ActionFuture get(final GetRequest request) { - return execute(GetAction.INSTANCE, request); + return execute(TransportGetAction.TYPE, request); } @Override public void get(final GetRequest request, final ActionListener listener) { - execute(GetAction.INSTANCE, request, listener); + execute(TransportGetAction.TYPE, request, listener); } @Override @@ -493,12 +493,12 @@ public GetRequestBuilder prepareGet(String index, String id) { @Override public ActionFuture multiGet(final MultiGetRequest request) { - return execute(MultiGetAction.INSTANCE, request); + return execute(TransportMultiGetAction.TYPE, request); } @Override public void multiGet(final MultiGetRequest request, final ActionListener listener) { - execute(MultiGetAction.INSTANCE, request, listener); + execute(TransportMultiGetAction.TYPE, request, listener); } @Override @@ -618,12 +618,12 @@ public ClearScrollRequestBuilder prepareClearScroll() { @Override public void fieldCaps(FieldCapabilitiesRequest request, ActionListener listener) { - execute(FieldCapabilitiesAction.INSTANCE, request, listener); + execute(TransportFieldCapabilitiesAction.TYPE, request, listener); } @Override public ActionFuture fieldCaps(FieldCapabilitiesRequest request) { - return execute(FieldCapabilitiesAction.INSTANCE, request); + return execute(TransportFieldCapabilitiesAction.TYPE, request); } @Override @@ -684,12 +684,12 @@ public ThreadPool threadPool() { @Override public ActionFuture health(final ClusterHealthRequest request) { - return execute(ClusterHealthAction.INSTANCE, request); + return execute(TransportClusterHealthAction.TYPE, request); } @Override public void health(final ClusterHealthRequest request, final ActionListener listener) { - execute(ClusterHealthAction.INSTANCE, request, listener); + execute(TransportClusterHealthAction.TYPE, request, listener); } @Override @@ -872,7 +872,7 @@ public PendingClusterTasksRequestBuilder preparePendingClusterTasks() { @Override public void pendingClusterTasks(PendingClusterTasksRequest request, ActionListener listener) { - execute(PendingClusterTasksAction.INSTANCE, request, listener); + execute(TransportPendingClusterTasksAction.TYPE, request, listener); } @Override @@ -1164,12 +1164,12 @@ public ThreadPool threadPool() { @Override public ActionFuture aliases(final IndicesAliasesRequest request) { - return execute(IndicesAliasesAction.INSTANCE, request); + return execute(TransportIndicesAliasesAction.TYPE, request); } @Override public void aliases(final IndicesAliasesRequest request, final ActionListener listener) { - execute(IndicesAliasesAction.INSTANCE, request, listener); + execute(TransportIndicesAliasesAction.TYPE, request, listener); } @Override @@ -1254,12 +1254,12 @@ public DeleteIndexRequestBuilder prepareDelete(String... indices) { @Override public ActionFuture close(final CloseIndexRequest request) { - return execute(CloseIndexAction.INSTANCE, request); + return execute(TransportCloseIndexAction.TYPE, request); } @Override public void close(final CloseIndexRequest request, final ActionListener listener) { - execute(CloseIndexAction.INSTANCE, request, listener); + execute(TransportCloseIndexAction.TYPE, request, listener); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestReloadAnalyzersAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestReloadAnalyzersAction.java index 0a93f964591a1..9c48d5285aae6 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestReloadAnalyzersAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestReloadAnalyzersAction.java @@ -8,8 +8,8 @@ package org.elasticsearch.rest.action.admin.indices; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersRequest; +import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; @@ -43,6 +43,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC Strings.splitStringByCommaToArray(request.param("index")) ); reloadAnalyzersRequest.indicesOptions(IndicesOptions.fromRequest(request, reloadAnalyzersRequest.indicesOptions())); - return channel -> client.execute(ReloadAnalyzerAction.INSTANCE, reloadAnalyzersRequest, new RestToXContentListener<>(channel)); + return channel -> client.execute( + TransportReloadAnalyzersAction.TYPE, + reloadAnalyzersRequest, + new RestToXContentListener<>(channel) + ); } } diff --git a/server/src/main/java/org/elasticsearch/script/package-info.java b/server/src/main/java/org/elasticsearch/script/package-info.java index 6365530e3f4c8..b96d46b2f4d77 100644 --- a/server/src/main/java/org/elasticsearch/script/package-info.java +++ b/server/src/main/java/org/elasticsearch/script/package-info.java @@ -9,6 +9,7 @@ /** * Support for running user provided scripts (in the request, in cluster state, etc) in portions of various requests * ({@link org.elasticsearch.common.lucene.search.function.FunctionScoreQuery}, {@link org.elasticsearch.search.aggregations.Aggregation}, - * {@link org.elasticsearch.action.update.UpdateAction}, etc). Pluggable via implementing {@link org.elasticsearch.plugins.ScriptPlugin}. + * {@link org.elasticsearch.action.update.TransportUpdateAction}, etc). Pluggable via implementing + * {@link org.elasticsearch.plugins.ScriptPlugin}. */ package org.elasticsearch.script; diff --git a/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java b/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java index 20aac833190a7..9409aef96d8be 100644 --- a/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java +++ b/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java @@ -18,9 +18,9 @@ import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersRequest; import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzersResponse; +import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.index.IndexRequest; @@ -468,7 +468,7 @@ private void reloadAnalyzers( // auto-reload all reloadable analyzers (currently only those that use updateable synonym or keyword_marker filters) ReloadAnalyzersRequest reloadAnalyzersRequest = new ReloadAnalyzersRequest(synonymSetId, preview, "*"); client.execute( - ReloadAnalyzerAction.INSTANCE, + TransportReloadAnalyzersAction.TYPE, reloadAnalyzersRequest, listener.safeMap(reloadResponse -> new SynonymsReloadResult(synonymsOperationResult, reloadResponse)) ); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateActionTests.java new file mode 100644 index 0000000000000..c8fb09b1e7177 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateActionTests.java @@ -0,0 +1,94 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.action.admin.indices.template.post; + +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; +import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.cluster.metadata.Template; +import org.elasticsearch.common.compress.CompressedXContent; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexSettingProvider; +import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.SystemIndices; +import org.elasticsearch.test.ESTestCase; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.is; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TransportSimulateIndexTemplateActionTests extends ESTestCase { + + public void testSettingsProviderIsOverridden() throws Exception { + String matchingTemplate = "test_template"; + String indexName = "test_index_name"; + CompressedXContent expectedMockMapping = new CompressedXContent(Map.of("key", "value")); + + boolean isDslOnlyMode = false; + ClusterState simulatedState = ClusterState.builder(new ClusterName("test_cluster")) + .metadata( + Metadata.builder() + .indexTemplates( + Map.of( + matchingTemplate, + ComposableIndexTemplate.builder() + .indexPatterns(List.of("test_index*")) + .template(new Template(Settings.builder().put("test-setting", 1).build(), null, null)) + .build() + ) + ) + ) + .build(); + + IndicesService indicesService = mock(IndicesService.class); + when(indicesService.withTempIndexService(any(IndexMetadata.class), any())).thenReturn(List.of()) // First call is mocked to return + // aliases + .thenReturn(expectedMockMapping); // Second call is mocked to return the merged mappings + + // This is not actually called in this test + SystemIndices systemIndices = mock(SystemIndices.class); + + // Create a setting provider that sets the test-setting to 0 + Set indexSettingsProviders = Set.of(new IndexSettingProvider() { + @Override + public Settings getAdditionalIndexSettings( + String indexName, + String dataStreamName, + boolean timeSeries, + Metadata metadata, + Instant resolvedAt, + Settings allSettings, + List combinedTemplateMappings + ) { + return Settings.builder().put("test-setting", 0).build(); + } + }); + + Template resolvedTemplate = TransportSimulateIndexTemplateAction.resolveTemplate( + matchingTemplate, + indexName, + simulatedState, + isDslOnlyMode, + xContentRegistry(), + indicesService, + systemIndices, + indexSettingsProviders + ); + + assertThat(resolvedTemplate.settings().getAsInt("test-setting", -1), is(1)); + } +} diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java index ab8308b3b9a55..bd5d260ad6e23 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java @@ -11,9 +11,9 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.action.support.AutoCreateIndex; @@ -173,7 +173,7 @@ class TestSingleItemBulkWriteAction extends TransportSingleItemBulkWriteAction[] ACTIONS = new ActionType[] { // client actions - GetAction.INSTANCE, + TransportGetAction.TYPE, TransportSearchAction.TYPE, - DeleteAction.INSTANCE, + TransportDeleteAction.TYPE, DeleteStoredScriptAction.INSTANCE, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, // cluster admin actions ClusterStatsAction.INSTANCE, @@ -96,9 +96,9 @@ public void testActions() { // validation in the settings??? - ugly and conceptually wrong) // choosing arbitrary top level actions to test - client.prepareGet("idx", "id").execute(new AssertingActionListener<>(GetAction.NAME, client.threadPool())); + client.prepareGet("idx", "id").execute(new AssertingActionListener<>(TransportGetAction.TYPE.name(), client.threadPool())); client.prepareSearch().execute(new AssertingActionListener<>(TransportSearchAction.TYPE.name(), client.threadPool())); - client.prepareDelete("idx", "id").execute(new AssertingActionListener<>(DeleteAction.NAME, client.threadPool())); + client.prepareDelete("idx", "id").execute(new AssertingActionListener<>(TransportDeleteAction.NAME, client.threadPool())); client.admin() .cluster() .prepareDeleteStoredScript("id") @@ -106,7 +106,7 @@ public void testActions() { client.prepareIndex("idx") .setId("id") .setSource("source", XContentType.JSON) - .execute(new AssertingActionListener<>(IndexAction.NAME, client.threadPool())); + .execute(new AssertingActionListener<>(TransportIndexAction.NAME, client.threadPool())); // choosing arbitrary cluster admin actions to test client.admin().cluster().prepareClusterStats().execute(new AssertingActionListener<>(ClusterStatsAction.NAME, client.threadPool())); @@ -132,7 +132,8 @@ public void testOverrideHeader() throws Exception { expected.put("key1", key1Val); expected.put("key2", "val 2"); client.threadPool().getThreadContext().putHeader("key1", key1Val); - client.prepareGet("idx", "id").execute(new AssertingActionListener<>(GetAction.NAME, expected, client.threadPool())); + client.prepareGet("idx", "id") + .execute(new AssertingActionListener<>(TransportGetAction.TYPE.name(), expected, client.threadPool())); client.admin() .cluster() diff --git a/server/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java b/server/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java index 3549b7a05d2b5..05e345bf4b52b 100644 --- a/server/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.cluster.health; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; @@ -159,7 +158,7 @@ public void testClusterHealthWaitsForClusterStateApplication() throws Interrupte PlainActionFuture listener = new PlainActionFuture<>(); ActionTestUtils.execute( action, - new CancellableTask(1, "direct", ClusterHealthAction.NAME, "", TaskId.EMPTY_TASK_ID, Map.of()), + new CancellableTask(1, "direct", TransportClusterHealthAction.NAME, "", TaskId.EMPTY_TASK_ID, Map.of()), new ClusterHealthRequest().waitForGreenStatus(), listener ); diff --git a/test/framework/src/integTest/java/org/elasticsearch/test/disruption/NetworkDisruptionIT.java b/test/framework/src/integTest/java/org/elasticsearch/test/disruption/NetworkDisruptionIT.java index 6d4fe25705688..88958063dbbf3 100644 --- a/test/framework/src/integTest/java/org/elasticsearch/test/disruption/NetworkDisruptionIT.java +++ b/test/framework/src/integTest/java/org/elasticsearch/test/disruption/NetworkDisruptionIT.java @@ -8,9 +8,9 @@ package org.elasticsearch.test.disruption; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.cluster.NodeConnectionsService; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; @@ -162,30 +162,35 @@ private static Tuple findDisruptedPair(Netwo } private static void sendRequest(TransportService source, TransportService target, CountDownLatch latch) { - source.sendRequest(target.getLocalNode(), ClusterHealthAction.NAME, new ClusterHealthRequest(), new TransportResponseHandler<>() { - private AtomicBoolean responded = new AtomicBoolean(); - - @Override - public Executor executor(ThreadPool threadPool) { - return TransportResponseHandler.TRANSPORT_WORKER; - } - - @Override - public void handleResponse(TransportResponse response) { - assertTrue(responded.compareAndSet(false, true)); - latch.countDown(); - } - - @Override - public void handleException(TransportException exp) { - assertTrue(responded.compareAndSet(false, true)); - latch.countDown(); - } - - @Override - public TransportResponse read(StreamInput in) throws IOException { - return ClusterHealthResponse.readResponseFrom(in); + source.sendRequest( + target.getLocalNode(), + TransportClusterHealthAction.NAME, + new ClusterHealthRequest(), + new TransportResponseHandler<>() { + private AtomicBoolean responded = new AtomicBoolean(); + + @Override + public Executor executor(ThreadPool threadPool) { + return TransportResponseHandler.TRANSPORT_WORKER; + } + + @Override + public void handleResponse(TransportResponse response) { + assertTrue(responded.compareAndSet(false, true)); + latch.countDown(); + } + + @Override + public void handleException(TransportException exp) { + assertTrue(responded.compareAndSet(false, true)); + latch.countDown(); + } + + @Override + public TransportResponse read(StreamInput in) throws IOException { + return ClusterHealthResponse.readResponseFrom(in); + } } - }); + ); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java index 09c7348cdc870..d3a20235e3a38 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java @@ -10,8 +10,8 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; @@ -77,7 +77,7 @@ public static void createAnnotationsIndexIfNecessaryAndWaitForYellow( executeAsyncWithOrigin( client, ML_ORIGIN, - ClusterHealthAction.INSTANCE, + TransportClusterHealthAction.TYPE, request, delegate.delegateFailureAndWrap((l, r) -> l.onResponse(r.isTimedOut() == false)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java index 2b622a1798508..d81541698e49b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java @@ -7,8 +7,8 @@ package org.elasticsearch.xpack.core.ml.job.persistence; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -109,7 +109,7 @@ public static void createStateIndexAndAliasIfNecessaryAndWaitForYellow( executeAsyncWithOrigin( client, ML_ORIGIN, - ClusterHealthAction.INSTANCE, + TransportClusterHealthAction.TYPE, request, delegate.delegateFailureAndWrap((l, r) -> l.onResponse(r.isTimedOut() == false)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java index 35c32780d2e4c..ca8932ced81b4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java @@ -11,7 +11,7 @@ import org.apache.lucene.util.automaton.Automaton; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; @@ -28,7 +28,7 @@ import org.elasticsearch.action.datastreams.DeleteDataStreamAction; import org.elasticsearch.action.datastreams.GetDataStreamAction; import org.elasticsearch.action.datastreams.PromoteDataStreamAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.search.TransportSearchShardsAction; import org.elasticsearch.common.Strings; import org.elasticsearch.index.seqno.RetentionLeaseActions; @@ -104,7 +104,7 @@ public final class IndexPrivilege extends Privilege { private static final Automaton MANAGE_AUTOMATON = unionAndMinimize( Arrays.asList( MONITOR_AUTOMATON, - patterns("indices:admin/*", FieldCapabilitiesAction.NAME + "*", GetRollupIndexCapsAction.NAME + "*") + patterns("indices:admin/*", TransportFieldCapabilitiesAction.NAME + "*", GetRollupIndexCapsAction.NAME + "*") ) ); private static final Automaton CREATE_INDEX_AUTOMATON = patterns( @@ -127,14 +127,14 @@ public final class IndexPrivilege extends Privilege { "indices:admin/data_stream/lifecycle/explain", GetDataStreamAction.NAME, ResolveIndexAction.NAME, - FieldCapabilitiesAction.NAME + "*", + TransportFieldCapabilitiesAction.NAME + "*", GetRollupIndexCapsAction.NAME + "*", GetCheckpointAction.NAME + "*" // transform internal action ); private static final Automaton MANAGE_FOLLOW_INDEX_AUTOMATON = patterns( PutFollowAction.NAME, UnfollowAction.NAME, - CloseIndexAction.NAME + "*", + TransportCloseIndexAction.NAME + "*", PromoteDataStreamAction.NAME, RolloverAction.NAME ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java index f11f5c450b270..fc0df87425239 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.core.security.authz.store; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.rollover.RolloverAction; @@ -298,7 +298,14 @@ static RoleDescriptor kibanaSystem(String name) { ".metrics-endpoint.metadata_current_default*", ".metrics-endpoint.metadata_united_default*" ) - .privileges("create_index", "delete_index", "read", "index", IndicesAliasesAction.NAME, UpdateSettingsAction.NAME) + .privileges( + "create_index", + "delete_index", + "read", + "index", + TransportIndicesAliasesAction.NAME, + UpdateSettingsAction.NAME + ) .build(), // For destination indices of the Threat Intel (ti_*) packages that ships a transform for supporting IOC expiration RoleDescriptor.IndicesPrivileges.builder() @@ -310,7 +317,7 @@ static RoleDescriptor kibanaSystem(String name) { "index", "delete", "manage", - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, UpdateSettingsAction.NAME ) .build(), @@ -334,7 +341,7 @@ static RoleDescriptor kibanaSystem(String name) { "read", "index", "view_index_metadata", - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, UpdateSettingsAction.NAME ) .build(), @@ -349,7 +356,7 @@ static RoleDescriptor kibanaSystem(String name) { "logs-cloud_security_posture.scores-default*", "logs-cloud_security_posture.vulnerabilities_latest-default*" ) - .privileges("create_index", "read", "index", "delete", IndicesAliasesAction.NAME, UpdateSettingsAction.NAME) + .privileges("create_index", "read", "index", "delete", TransportIndicesAliasesAction.NAME, UpdateSettingsAction.NAME) .build(), RoleDescriptor.IndicesPrivileges.builder().indices("risk-score.risk-*").privileges("all").build(), RoleDescriptor.IndicesPrivileges.builder() diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index da8e97b10dc87..96eaec5d93158 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -9,7 +9,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.remote.TransportRemoteInfoAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.rollover.RolloverAction; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Setting; @@ -212,7 +212,13 @@ private static Map initializeReservedRoles() { RoleDescriptor.IndicesPrivileges.builder().indices(".monitoring-*").privileges("all").build(), RoleDescriptor.IndicesPrivileges.builder() .indices("metricbeat-*") - .privileges("index", "create_index", "view_index_metadata", IndicesAliasesAction.NAME, RolloverAction.NAME) + .privileges( + "index", + "create_index", + "view_index_metadata", + TransportIndicesAliasesAction.NAME, + RolloverAction.NAME + ) .build() }, null, MetadataUtils.DEFAULT_RESERVED_METADATA diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java index 652d6815eea46..0cc5c9367ea50 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.core.security.user; -import org.elasticsearch.action.admin.indices.analyze.ReloadAnalyzerAction; +import org.elasticsearch.action.admin.indices.analyze.TransportReloadAnalyzersAction; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeAction; import org.elasticsearch.action.admin.indices.readonly.AddIndexBlockAction; import org.elasticsearch.action.admin.indices.refresh.RefreshAction; @@ -189,7 +189,7 @@ public class InternalUsers { null, new RoleDescriptor.IndicesPrivileges[] { RoleDescriptor.IndicesPrivileges.builder().indices(".synonyms*").privileges("all").allowRestrictedIndices(true).build(), - RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges(ReloadAnalyzerAction.NAME).build(), }, + RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges(TransportReloadAnalyzersAction.TYPE.name()).build(), }, null, null, null, diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java index 99826b5537258..b98a8abc019d0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java @@ -9,9 +9,9 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.TransportVersions; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.ShardSearchFailure; @@ -110,7 +110,7 @@ public void testExecuteWithClient() throws Exception { }).when(client).execute(any(), any(), any()); threadContext.putHeader(headerName, headerValue); - ClientHelper.executeAsyncWithOrigin(client, origin, ClusterHealthAction.INSTANCE, new ClusterHealthRequest(), listener); + ClientHelper.executeAsyncWithOrigin(client, origin, TransportClusterHealthAction.TYPE, new ClusterHealthRequest(), listener); latch.await(); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/common/notifications/AbstractAuditorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/common/notifications/AbstractAuditorTests.java index 5fed17f45246d..ccb3af23973e7 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/common/notifications/AbstractAuditorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/common/notifications/AbstractAuditorTests.java @@ -11,8 +11,8 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.internal.AdminClient; import org.elasticsearch.client.internal.Client; @@ -99,7 +99,7 @@ public void testInfo() throws IOException { AbstractAuditor auditor = createTestAuditorWithTemplateInstalled(); auditor.info("foo", "Here is my info"); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); IndexRequest indexRequest = indexRequestCaptor.getValue(); assertThat(indexRequest.indices(), arrayContaining(TEST_INDEX)); assertThat(indexRequest.timeout(), equalTo(TimeValue.timeValueSeconds(5))); @@ -118,7 +118,7 @@ public void testWarning() throws IOException { AbstractAuditor auditor = createTestAuditorWithTemplateInstalled(); auditor.warning("bar", "Here is my warning"); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); IndexRequest indexRequest = indexRequestCaptor.getValue(); assertThat(indexRequest.indices(), arrayContaining(TEST_INDEX)); assertThat(indexRequest.timeout(), equalTo(TimeValue.timeValueSeconds(5))); @@ -137,7 +137,7 @@ public void testError() throws IOException { AbstractAuditor auditor = createTestAuditorWithTemplateInstalled(); auditor.error("foobar", "Here is my error"); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); IndexRequest indexRequest = indexRequestCaptor.getValue(); assertThat(indexRequest.indices(), arrayContaining(TEST_INDEX)); assertThat(indexRequest.timeout(), equalTo(TimeValue.timeValueSeconds(5))); @@ -158,7 +158,7 @@ public void testAudit() throws IOException { AbstractAuditor auditor = createTestAuditorWithTemplateInstalled(); auditor.audit(level, "r_id", "Here is my audit"); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); IndexRequest indexRequest = indexRequestCaptor.getValue(); assertThat(indexRequest.indices(), arrayContaining(TEST_INDEX)); assertThat(indexRequest.timeout(), equalTo(TimeValue.timeValueSeconds(5))); @@ -183,7 +183,7 @@ public void testAuditingBeforeTemplateInstalled() throws Exception { auditor.warning("foobar", "Here is my warning to queue"); auditor.info("foobar", "Here is my info to queue"); - verify(client, never()).execute(eq(IndexAction.INSTANCE), any(), any()); + verify(client, never()).execute(eq(TransportIndexAction.TYPE), any(), any()); // fire the put template response writeSomeDocsBeforeTemplateLatch.countDown(); @@ -195,7 +195,7 @@ public void testAuditingBeforeTemplateInstalled() throws Exception { assertThat(bulkRequest.numberOfActions(), equalTo(3)); auditor.info("foobar", "Here is another message"); - verify(client, times(1)).execute(eq(IndexAction.INSTANCE), any(), any()); + verify(client, times(1)).execute(eq(TransportIndexAction.TYPE), any(), any()); } public void testMaxBufferSize() throws Exception { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStepTests.java index 7a09b375ed53b..f9f06b10ad2f9 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SwapAliasesAndDeleteSourceIndexStepTests.java @@ -10,9 +10,9 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -134,7 +134,7 @@ protected void Request request, ActionListener listener ) { - assertThat(action.name(), is(IndicesAliasesAction.NAME)); + assertThat(action.name(), is(TransportIndicesAliasesAction.NAME)); assertTrue(request instanceof IndicesAliasesRequest); assertThat(((IndicesAliasesRequest) request).getAliasActions(), equalTo(expectedAliasActions)); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java index 9dde594653367..b755d3497f649 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java @@ -11,10 +11,10 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshAction; import org.elasticsearch.action.admin.indices.shrink.ShrinkAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.TransportSearchAction; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.common.util.iterable.Iterables; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction; @@ -60,9 +60,9 @@ public void testOrderingOfPrivilegeNames() throws Exception { public void testFindPrivilegesThatGrant() { assertThat(findPrivilegesThatGrant(TransportSearchAction.TYPE.name()), equalTo(List.of("read", "all"))); - assertThat(findPrivilegesThatGrant(IndexAction.NAME), equalTo(List.of("create_doc", "create", "index", "write", "all"))); - assertThat(findPrivilegesThatGrant(UpdateAction.NAME), equalTo(List.of("index", "write", "all"))); - assertThat(findPrivilegesThatGrant(DeleteAction.NAME), equalTo(List.of("delete", "write", "all"))); + assertThat(findPrivilegesThatGrant(TransportIndexAction.NAME), equalTo(List.of("create_doc", "create", "index", "write", "all"))); + assertThat(findPrivilegesThatGrant(TransportUpdateAction.NAME), equalTo(List.of("index", "write", "all"))); + assertThat(findPrivilegesThatGrant(TransportDeleteAction.NAME), equalTo(List.of("delete", "write", "all"))); assertThat( findPrivilegesThatGrant(IndicesStatsAction.NAME), equalTo(List.of("monitor", "cross_cluster_replication", "manage", "all")) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/PrivilegeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/PrivilegeTests.java index 59add1cac3539..2e2368ece0612 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/PrivilegeTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/PrivilegeTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.core.security.authz.privilege; import org.apache.lucene.util.automaton.Operations; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksAction; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; @@ -301,7 +301,7 @@ public void testReadSecurityPrivilege() { CreateServiceAccountTokenAction.NAME, CreateApiKeyAction.NAME, InvalidateApiKeyAction.NAME, - ClusterHealthAction.NAME, + TransportClusterHealthAction.NAME, ClusterStateAction.NAME, ClusterStatsAction.NAME, NodeEnrollmentAction.NAME, @@ -353,7 +353,7 @@ public void testManageUserProfilePrivilege() { ); verifyClusterActionDenied( ClusterPrivilegeResolver.MANAGE_USER_PROFILE, - ClusterHealthAction.NAME, + TransportClusterHealthAction.NAME, ClusterStateAction.NAME, ClusterStatsAction.NAME, PutIndexTemplateAction.NAME, diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java index 6ee70173f505e..ed77e9a1d4d9a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.core.security.authz.store; import org.elasticsearch.Version; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.remote.TransportRemoteInfoAction; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesAction; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryAction; @@ -19,7 +19,7 @@ import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; @@ -44,10 +44,10 @@ import org.elasticsearch.action.datastreams.CreateDataStreamAction; import org.elasticsearch.action.datastreams.DeleteDataStreamAction; import org.elasticsearch.action.datastreams.GetDataStreamAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; -import org.elasticsearch.action.get.GetAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.ingest.DeletePipelineAction; import org.elasticsearch.action.ingest.GetPipelineAction; import org.elasticsearch.action.ingest.PutPipelineAction; @@ -57,7 +57,7 @@ import org.elasticsearch.action.search.TransportSearchShardsAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.cluster.metadata.AliasMetadata; import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -328,7 +328,7 @@ public void testSnapshotUserRole() { assertThat( snapshotUserRole.indices() - .allowedIndicesMatcher(IndexAction.NAME) + .allowedIndicesMatcher(TransportIndexAction.NAME) .test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); @@ -337,11 +337,15 @@ public void testSnapshotUserRole() { is(false) ); assertThat( - snapshotUserRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), + snapshotUserRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); assertThat( - snapshotUserRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), + snapshotUserRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); @@ -393,13 +397,15 @@ public void testIngestAdminRole() { assertThat(ingestAdminRole.cluster().check(GetProfilesAction.NAME, request, authentication), is(false)); assertThat(ingestAdminRole.cluster().check(ProfileHasPrivilegesAction.NAME, request, authentication), is(false)); - assertThat(ingestAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat(ingestAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); assertThat( ingestAdminRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); assertThat( - ingestAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), + ingestAdminRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); @@ -419,7 +425,7 @@ public void testKibanaSystemRole() { assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true)); Role kibanaRole = Role.buildFromRoleDescriptor(roleDescriptor, new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES); - assertThat(kibanaRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(kibanaRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(kibanaRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(kibanaRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(kibanaRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(true)); @@ -581,8 +587,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); assertThat(kibanaRole.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); assertThat( kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) @@ -612,8 +621,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -623,7 +632,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true)); }); @@ -637,8 +649,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -648,7 +660,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false)); }); @@ -662,8 +677,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -673,7 +688,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false)); }); @@ -684,8 +702,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -695,7 +713,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true)); }); @@ -710,8 +731,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) @@ -720,7 +741,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true)); }); @@ -730,8 +754,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) @@ -740,7 +764,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false)); // Privileges needed for Fleet package upgrades @@ -759,11 +786,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -778,11 +805,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -804,14 +831,14 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(dotFleetSecretsIndex), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(dotFleetSecretsIndex), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(dotFleetSecretsIndex), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(dotFleetSecretsIndex), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(dotFleetSecretsIndex), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(dotFleetSecretsIndex), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(dotFleetSecretsIndex), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(false) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(dotFleetSecretsIndex), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(dotFleetSecretsIndex), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(dotFleetSecretsIndex), is(false)); assertThat(kibanaRole.cluster().check("cluster:admin/fleet/secrets/get", request, authentication), is(false)); @@ -824,8 +851,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) @@ -834,7 +861,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); }); // read-only index for Endpoint and Osquery manager specific action responses @@ -845,11 +875,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -863,11 +893,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -882,11 +912,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -901,11 +931,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -922,8 +952,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -933,7 +963,10 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(false) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false)); }); @@ -967,11 +1000,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -986,11 +1019,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -1003,8 +1036,8 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -1014,7 +1047,7 @@ public void testKibanaSystemRole() { kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false)); assertNoAccessAllowed(kibanaRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); @@ -1076,8 +1109,14 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(indexAbstraction), is(isAlsoAutoCreateIndex)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateDataStreamAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(isAlsoAutoCreateIndex)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(isAlsoAutoCreateIndex)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), + is(isAlsoAutoCreateIndex) + ); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), + is(isAlsoAutoCreateIndex) + ); // Endpoint diagnostic and actions data streams also have read access, all others should not. final boolean isAlsoReadIndex = indexName.startsWith(".logs-endpoint.diagnostic.collection-") @@ -1085,7 +1124,10 @@ public void testKibanaSystemRole() { || indexName.startsWith(".logs-endpoint.action.responses-") || indexName.startsWith(".logs-endpoint.heartbeat-") || indexName.startsWith(".logs-osquery_manager.actions-"); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(isAlsoReadIndex)); + assertThat( + kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), + is(isAlsoReadIndex) + ); assertThat( kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(isAlsoReadIndex) @@ -1142,9 +1184,9 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); // Allow indexing assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); @@ -1153,7 +1195,7 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteDataStreamAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndicesAliasesAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); // Implied by the overall view_index_metadata and monitor privilege @@ -1170,7 +1212,7 @@ public void testKibanaSystemRole() { ); // Deny deleting documents and rollover - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(false)); }); @@ -1180,19 +1222,19 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); // Allow search and indexing assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndicesAliasesAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); // Allow deleting documents - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(true)); // Implied by the overall view_index_metadata and monitor privilege assertViewIndexMetadata(kibanaRole, indexName); @@ -1215,15 +1257,15 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); // Implied by the overall view_index_metadata and monitor privilege assertViewIndexMetadata(kibanaRole, indexName); @@ -1241,9 +1283,9 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); // Allow indexing assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); @@ -1266,11 +1308,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -1284,11 +1326,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -1307,16 +1349,16 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); // Allow indexing assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateDataStreamAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndicesAliasesAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); // Implied by the overall view_index_metadata and monitor privilege @@ -1341,11 +1383,11 @@ public void testKibanaSystemRole() { assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true)); @@ -1382,15 +1424,15 @@ public void testKibanaSystemRole() { final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName); // Allow search and indexing assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true)); // Allow create and delete index, modifying aliases, and updating index settings assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true)); - assertThat(kibanaRole.indices().allowedIndicesMatcher(IndicesAliasesAction.NAME).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true)); assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true)); // Implied by the overall view_index_metadata and monitor privilege @@ -1428,7 +1470,7 @@ public void testKibanaAdminRole() { RESTRICTED_INDICES, List.of(new ApplicationPrivilegeDescriptor("kibana-.kibana", "all", Set.of(allowedApplicationActionPattern), Map.of())) ); - assertThat(kibanaAdminRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(kibanaAdminRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(kibanaAdminRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(kibanaAdminRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(kibanaAdminRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -1439,8 +1481,11 @@ public void testKibanaAdminRole() { assertThat(kibanaAdminRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); - assertThat(kibanaAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(kibanaAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); + assertThat(kibanaAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat( + kibanaAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); assertThat( kibanaAdminRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) @@ -1489,7 +1534,7 @@ public void testKibanaUserRole() { RESTRICTED_INDICES, List.of(new ApplicationPrivilegeDescriptor("kibana-.kibana", "all", Set.of(allowedApplicationActionPattern), Map.of())) ); - assertThat(kibanaUserRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(kibanaUserRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(kibanaUserRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(kibanaUserRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(kibanaUserRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -1500,8 +1545,11 @@ public void testKibanaUserRole() { assertThat(kibanaUserRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false)); - assertThat(kibanaUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(kibanaUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); + assertThat(kibanaUserRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat( + kibanaUserRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); assertThat( kibanaUserRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) @@ -1569,7 +1617,7 @@ public void testMonitoringUserRole() { assertThat(monitoringUserRole.cluster().check(MainRestPlugin.MAIN_ACTION.name(), request, authentication), is(true)); assertThat(monitoringUserRole.cluster().check(XPackInfoAction.NAME, request, authentication), is(true)); assertThat(monitoringUserRole.cluster().check(TransportRemoteInfoAction.TYPE.name(), request, authentication), is(true)); - assertThat(monitoringUserRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(monitoringUserRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(monitoringUserRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(monitoringUserRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(monitoringUserRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -1619,8 +1667,14 @@ public void testMonitoringUserRole() { assertThat(monitoringUserRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(monitoringUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(monitoringUserRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + monitoringUserRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); + assertThat( + monitoringUserRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); assertThat( monitoringUserRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false) @@ -1629,7 +1683,10 @@ public void testMonitoringUserRole() { monitoringUserRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(monitoringUserRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + monitoringUserRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(monitoringUserRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true)); assertNoAccessAllowed(monitoringUserRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); @@ -1693,7 +1750,7 @@ public void testRemoteMonitoringAgentRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(remoteMonitoringAgentRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(remoteMonitoringAgentRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringAgentRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringAgentRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringAgentRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(true)); @@ -1763,11 +1820,15 @@ public void testRemoteMonitoringAgentRole() { is(true) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(monitoringIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportIndexAction.NAME) + .test(mockIndexAbstraction(monitoringIndex)), is(true) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(monitoringIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportDeleteAction.NAME) + .test(mockIndexAbstraction(monitoringIndex)), is(true) ); assertThat( @@ -1783,7 +1844,9 @@ public void testRemoteMonitoringAgentRole() { is(true) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(monitoringIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(monitoringIndex)), is(true) ); assertThat( @@ -1809,7 +1872,9 @@ public void testRemoteMonitoringAgentRole() { is(true) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(metricbeatIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportIndexAction.NAME) + .test(mockIndexAbstraction(metricbeatIndex)), is(true) ); assertThat( @@ -1822,7 +1887,7 @@ public void testRemoteMonitoringAgentRole() { ); assertThat( remoteMonitoringAgentRole.indices() - .allowedIndicesMatcher(IndicesAliasesAction.NAME) + .allowedIndicesMatcher(TransportIndicesAliasesAction.NAME) .test(mockIndexAbstraction(metricbeatIndex)), is(true) ); @@ -1843,7 +1908,9 @@ public void testRemoteMonitoringAgentRole() { is(false) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(metricbeatIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportDeleteAction.NAME) + .test(mockIndexAbstraction(metricbeatIndex)), is(false) ); assertThat( @@ -1859,7 +1926,9 @@ public void testRemoteMonitoringAgentRole() { is(false) ); assertThat( - remoteMonitoringAgentRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(metricbeatIndex)), + remoteMonitoringAgentRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(metricbeatIndex)), is(false) ); @@ -1880,7 +1949,7 @@ public void testRemoteMonitoringCollectorRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(remoteMonitoringCollectorRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(remoteMonitoringCollectorRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringCollectorRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringCollectorRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(remoteMonitoringCollectorRole.cluster().check(GetIndexTemplatesAction.NAME, request, authentication), is(true)); @@ -1916,7 +1985,9 @@ public void testRemoteMonitoringCollectorRole() { is(true) ); assertThat( - remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(".kibana")), + remoteMonitoringCollectorRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(".kibana")), is(true) ); assertThat( @@ -1948,7 +2019,7 @@ public void testRemoteMonitoringCollectorRole() { is(false) ); assertThat( - remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), + remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false) ); assertThat( @@ -1966,7 +2037,7 @@ public void testRemoteMonitoringCollectorRole() { is(false) ); assertThat( - remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), + remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false) ); assertThat( @@ -1980,7 +2051,9 @@ public void testRemoteMonitoringCollectorRole() { is(false) ); assertThat( - remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), + remoteMonitoringCollectorRole.indices() + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) + .test(mockIndexAbstraction(index)), is(false) ); assertThat( @@ -2066,37 +2139,37 @@ public void testRemoteMonitoringCollectorRole() { ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(GetAction.NAME) + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) .test(mockIndexAbstraction(randomFrom(TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES))), is(false) ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(GetAction.NAME) + .allowedIndicesMatcher(TransportGetAction.TYPE.name()) .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false) ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(DeleteAction.NAME) + .allowedIndicesMatcher(TransportDeleteAction.NAME) .test(mockIndexAbstraction(randomFrom(TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES))), is(false) ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(DeleteAction.NAME) + .allowedIndicesMatcher(TransportDeleteAction.NAME) .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false) ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(IndexAction.NAME) + .allowedIndicesMatcher(TransportIndexAction.NAME) .test(mockIndexAbstraction(randomFrom(TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES))), is(false) ); assertThat( remoteMonitoringCollectorRole.indices() - .allowedIndicesMatcher(IndexAction.NAME) + .allowedIndicesMatcher(TransportIndexAction.NAME) .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false) ); @@ -2158,7 +2231,7 @@ public void testReportingUserRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(reportingUserRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(reportingUserRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(reportingUserRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(reportingUserRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(reportingUserRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -2199,10 +2272,22 @@ public void testReportingUserRole() { reportingUserRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(false) ); - assertThat(reportingUserRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(reportingUserRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(reportingUserRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(reportingUserRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat( + reportingUserRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(false) + ); + assertThat( + reportingUserRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); + assertThat( + reportingUserRole.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); + assertThat( + reportingUserRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(reportingUserRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertNoAccessAllowed(reportingUserRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); @@ -2218,7 +2303,7 @@ public void testSuperuserRole() { assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true)); Role superuserRole = Role.buildFromRoleDescriptor(roleDescriptor, new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES); - assertThat(superuserRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(superuserRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(superuserRole.cluster().check(ClusterUpdateSettingsAction.NAME, request, authentication), is(true)); assertThat(superuserRole.cluster().check(PutUserAction.NAME, request, authentication), is(true)); assertThat(superuserRole.cluster().check(PutRoleAction.NAME, request, authentication), is(true)); @@ -2273,7 +2358,7 @@ public void testSuperuserRole() { iac = superuserRole.indices().authorize(DeleteIndexAction.NAME, Sets.newHashSet("a1", "ba"), lookup, fieldPermissionsCache); assertThat(iac.hasIndexPermissions("a1"), is(true)); assertThat(iac.hasIndexPermissions("b"), is(true)); - iac = superuserRole.indices().authorize(IndexAction.NAME, Sets.newHashSet("a2", "ba"), lookup, fieldPermissionsCache); + iac = superuserRole.indices().authorize(TransportIndexAction.NAME, Sets.newHashSet("a2", "ba"), lookup, fieldPermissionsCache); assertThat(iac.hasIndexPermissions("a2"), is(true)); assertThat(iac.hasIndexPermissions("b"), is(true)); iac = superuserRole.indices().authorize(UpdateSettingsAction.NAME, Sets.newHashSet("aaaaaa", "ba"), lookup, fieldPermissionsCache); @@ -2294,7 +2379,7 @@ public void testSuperuserRole() { // Write security indices => denied iac = superuserRole.indices() .authorize( - randomFrom(IndexAction.NAME, DeleteIndexAction.NAME), + randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME), Sets.newHashSet(TestRestrictedIndices.SECURITY_MAIN_ALIAS), lookup, fieldPermissionsCache @@ -2310,13 +2395,13 @@ public void testSuperuserRole() { // Read security indices => allowed assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(GetAction.NAME, IndicesStatsAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportGetAction.TYPE.name(), IndicesStatsAction.NAME)) .test(mockIndexAbstraction(TestRestrictedIndices.SECURITY_MAIN_ALIAS)), is(true) ); assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(GetAction.NAME, IndicesStatsAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportGetAction.TYPE.name(), IndicesStatsAction.NAME)) .test(mockIndexAbstraction(internalSecurityIndex)), is(true) ); @@ -2324,13 +2409,13 @@ public void testSuperuserRole() { // Write security indices => denied assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(IndexAction.NAME, DeleteIndexAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME)) .test(mockIndexAbstraction(TestRestrictedIndices.SECURITY_MAIN_ALIAS)), is(false) ); assertThat( superuserRole.indices() - .allowedIndicesMatcher(randomFrom(IndexAction.NAME, DeleteIndexAction.NAME)) + .allowedIndicesMatcher(randomFrom(TransportIndexAction.NAME, DeleteIndexAction.NAME)) .test(mockIndexAbstraction(internalSecurityIndex)), is(false) ); @@ -2349,7 +2434,7 @@ public void testLogstashSystemRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(logstashSystemRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(logstashSystemRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(logstashSystemRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(logstashSystemRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(logstashSystemRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -2360,9 +2445,12 @@ public void testLogstashSystemRole() { assertThat(logstashSystemRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); - assertThat(logstashSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); assertThat( - logstashSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), + logstashSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), + is(false) + ); + assertThat( + logstashSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false) ); assertThat( @@ -2387,7 +2475,7 @@ public void testBeatsAdminRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(beatsAdminRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(beatsAdminRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(beatsAdminRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(beatsAdminRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(beatsAdminRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -2414,8 +2502,8 @@ public void testBeatsAdminRole() { assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:bar").test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(beatsAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(beatsAdminRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(beatsAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(beatsAdminRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(beatsAdminRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat( beatsAdminRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), @@ -2425,7 +2513,10 @@ public void testBeatsAdminRole() { beatsAdminRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(beatsAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + beatsAdminRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertNoAccessAllowed(beatsAdminRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); assertNoAccessAllowed(beatsAdminRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2)); @@ -2440,7 +2531,7 @@ public void testBeatsSystemRole() { assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true)); Role beatsSystemRole = Role.buildFromRoleDescriptor(roleDescriptor, new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES); - assertThat(beatsSystemRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(beatsSystemRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(beatsSystemRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(beatsSystemRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(beatsSystemRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -2458,15 +2549,21 @@ public void testBeatsSystemRole() { final String index = ".monitoring-beats-" + randomIntBetween(0, 5); logger.info("beats monitoring index name [{}]", index); - assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); + assertThat(beatsSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat( + beatsSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); assertThat( beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) ); assertThat(beatsSystemRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(beatsSystemRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(beatsSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + beatsSystemRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), + is(false) + ); assertThat(beatsSystemRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertNoAccessAllowed(beatsSystemRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); @@ -2482,7 +2579,7 @@ public void testAPMSystemRole() { assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true)); Role APMSystemRole = Role.buildFromRoleDescriptor(roleDescriptor, new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES); - assertThat(APMSystemRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(APMSystemRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); assertThat(APMSystemRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(true)); assertThat(APMSystemRole.cluster().check(ClusterStatsAction.NAME, request, authentication), is(true)); assertThat(APMSystemRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -2493,8 +2590,11 @@ public void testAPMSystemRole() { assertThat(APMSystemRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); - assertThat(APMSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(APMSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); + assertThat(APMSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat( + APMSystemRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); assertThat( APMSystemRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) @@ -2508,7 +2608,7 @@ public void testAPMSystemRole() { APMSystemRole.indices().allowedIndicesMatcher("indices:data/write/index:op_type/create").test(mockIndexAbstraction(index)), is(true) ); - assertThat(APMSystemRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(APMSystemRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(APMSystemRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat( @@ -3077,7 +3177,7 @@ public void testWatcherAdminRole() { assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); for (String index : new String[] { Watch.INDEX, HistoryStoreField.DATA_STREAM, TriggeredWatchStoreField.INDEX_NAME }) { assertOnlyReadAllowed(role, index); @@ -3108,9 +3208,9 @@ public void testWatcherUserRole() { assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); assertThat( - role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(TriggeredWatchStoreField.INDEX_NAME)), + role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(TriggeredWatchStoreField.INDEX_NAME)), is(false) ); @@ -3138,7 +3238,7 @@ public void testPredefinedViewerRole() { List.of(new ApplicationPrivilegeDescriptor("kibana-.kibana", "read", Set.of(allowedApplicationActionPattern), Map.of())) ); // No cluster privileges - assertThat(role.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(role.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -3212,7 +3312,7 @@ public void testPredefinedEditorRole() { ); // No cluster privileges - assertThat(role.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(role.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(ClusterStateAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(ClusterStatsAction.NAME, request, authentication), is(false)); assertThat(role.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); @@ -3328,15 +3428,15 @@ private void assertAllIndicesAccessAllowed(Role role, String index) { assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); assertThat( role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) ); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); // inherits from 'all' assertThat(role.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true)); } @@ -3344,10 +3444,10 @@ private void assertAllIndicesAccessAllowed(Role role, String index) { private void assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(Role role, String index) { assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(UpdateAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher("indices:admin/refresh*").test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher("indices:admin/flush*").test(mockIndexAbstraction(index)), is(true)); @@ -3358,10 +3458,10 @@ private void assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(Role role private void assertReadWriteDocsButNotDeleteIndexAllowed(Role role, String index) { assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(UpdateAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(true)); } @@ -3370,10 +3470,10 @@ private void assertOnlyReadAllowed(Role role, String index) { assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(UpdateAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertNoAccessAllowed(role, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES); @@ -3393,7 +3493,7 @@ private void assertViewIndexMetadata(Role role, String index) { ExplainLifecycleAction.NAME, GetDataStreamAction.NAME, ResolveIndexAction.NAME, - FieldCapabilitiesAction.NAME + "*", + TransportFieldCapabilitiesAction.NAME + "*", GetRollupIndexCapsAction.NAME + "*" ).forEach(action -> assertThat(role.indices().allowedIndicesMatcher(action).test(mockIndexAbstraction(index)), is(true))); } @@ -3409,10 +3509,10 @@ private void assertNoAccessAllowed(Role role, String index) { assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(UpdateAction.NAME).test(mockIndexAbstraction(index)), is(false)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(false)); } @@ -3429,7 +3529,7 @@ public void testLogstashAdminRole() { new FieldPermissionsCache(Settings.EMPTY), RESTRICTED_INDICES ); - assertThat(logstashAdminRole.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false)); + assertThat(logstashAdminRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false)); assertThat(logstashAdminRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(false)); assertThat(logstashAdminRole.cluster().check(ClusterRerouteAction.NAME, request, authentication), is(false)); assertThat(logstashAdminRole.cluster().check(ClusterUpdateSettingsAction.NAME, request, authentication), is(false)); @@ -3441,9 +3541,18 @@ public void testLogstashAdminRole() { assertThat(logstashAdminRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false)); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo")), is(false)); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".reporting")), is(false)); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(".logstash")), is(true)); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo")), + is(false) + ); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".reporting")), + is(false) + ); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(".logstash")), + is(true) + ); assertThat( logstashAdminRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false) @@ -3451,11 +3560,20 @@ public void testLogstashAdminRole() { final String index = ".logstash-" + randomIntBetween(0, 5); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), + is(true) + ); assertThat(logstashAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); assertThat(logstashAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(true)); - assertThat(logstashAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true)); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), + is(true) + ); + assertThat( + logstashAdminRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), + is(true) + ); assertThat( logstashAdminRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true) @@ -3561,7 +3679,7 @@ public void testEnrichUserRole() { assertTrue(role.cluster().check("cluster:admin/xpack/enrich/esql/resolve", request, authentication)); assertTrue(role.cluster().check("cluster:admin/xpack/enrich/esql/lookup", request, authentication)); assertFalse(role.runAs().check(randomAlphaOfLengthBetween(1, 30))); - assertFalse(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction("foo"))); + assertFalse(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction("foo"))); assertOnlyReadAllowed(role, ".enrich-foo"); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java index 6603353e967ea..f9a12b1fecf0b 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/user/InternalUsersTests.java @@ -27,7 +27,7 @@ import org.elasticsearch.action.admin.indices.template.put.PutComponentTemplateAction; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.downsample.DownsampleAction; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -87,7 +87,7 @@ public void testXPackUser() { checkClusterAccess(InternalUsers.XPACK_USER, role, randomFrom(sampleClusterActions), true); final List sampleIndexActions = List.of( - GetAction.NAME, + TransportGetAction.TYPE.name(), BulkAction.NAME, RefreshAction.NAME, CreateIndexAction.NAME, @@ -122,7 +122,7 @@ public void testXPackSecurityUser() { checkClusterAccess(InternalUsers.XPACK_SECURITY_USER, role, randomFrom(sampleClusterActions), true); final List sampleIndexActions = List.of( - GetAction.NAME, + TransportGetAction.TYPE.name(), BulkAction.NAME, RefreshAction.NAME, CreateIndexAction.NAME, @@ -149,7 +149,7 @@ public void testSecurityProfileUser() { assertThat(role.remoteIndices(), is(RemoteIndicesPermission.NONE)); final List sampleAllowedActions = List.of( - GetAction.NAME, + TransportGetAction.TYPE.name(), BulkAction.NAME, RefreshAction.NAME, CreateIndexAction.NAME, @@ -180,7 +180,7 @@ public void testAsyncSearchUser() { checkClusterAccess(InternalUsers.ASYNC_SEARCH_USER, role, ClusterStateAction.NAME, false); final List sampleAllowedActions = List.of( - GetAction.NAME, + TransportGetAction.TYPE.name(), BulkAction.NAME, RefreshAction.NAME, CreateIndexAction.NAME, @@ -212,7 +212,12 @@ public void testStorageUser() { checkIndexAccess(role, randomFrom(sampleAllowedActions), ".ds-" + randomAlphaOfLengthBetween(4, 8), true); checkIndexAccess(role, randomFrom(sampleAllowedActions), INTERNAL_SECURITY_MAIN_INDEX_7, true); - final List sampleDeniedActions = List.of(GetAction.NAME, BulkAction.NAME, PutMappingAction.NAME, DeleteIndexAction.NAME); + final List sampleDeniedActions = List.of( + TransportGetAction.TYPE.name(), + BulkAction.NAME, + PutMappingAction.NAME, + DeleteIndexAction.NAME + ); checkIndexAccess(role, randomFrom(sampleDeniedActions), randomAlphaOfLengthBetween(4, 8), false); checkIndexAccess(role, randomFrom(sampleDeniedActions), ".ds-" + randomAlphaOfLengthBetween(4, 8), false); checkIndexAccess(role, randomFrom(sampleDeniedActions), INTERNAL_SECURITY_MAIN_INDEX_7, false); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index aac9f5e74cf0e..9ab7f7dea9b2d 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.ActionType; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.LatchedActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; @@ -2071,7 +2071,7 @@ public void testRunnerCancel() throws Exception { RefreshAction.INSTANCE, IndicesSegmentsAction.INSTANCE, UpdateSettingsAction.INSTANCE, - ClusterHealthAction.INSTANCE + TransportClusterHealthAction.TYPE ); logger.info("Selected [{}] to perform cancel", randomActionType.name()); Client client = new FilterClient(client()) { diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/rules/RuleQueryBuilderTests.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/rules/RuleQueryBuilderTests.java index c2876a9b9ee4d..1d19011fdd4a9 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/rules/RuleQueryBuilderTests.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/rules/RuleQueryBuilderTests.java @@ -11,9 +11,9 @@ import org.apache.lucene.search.Query; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.ElasticsearchClient; import org.elasticsearch.common.ParsingException; @@ -131,7 +131,7 @@ protected Object simulateMethod(Method method, Object[] args) { // Get request, to pull the query ruleset from the system index using clientWithOrigin if (method.getDeclaringClass().equals(ElasticsearchClient.class) && method.getName().equals("execute") - && args[0] instanceof GetAction) { + && args[0] == TransportGetAction.TYPE) { GetRequest getRequest = (GetRequest) args[1]; assertThat(getRequest.index(), Matchers.equalTo(QueryRulesIndexService.QUERY_RULES_ALIAS_NAME)); diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java index 9e43cc15f48cf..c0a286cc5c464 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilterChain; import org.elasticsearch.common.settings.Settings; @@ -195,7 +195,7 @@ public void app ActionFilterChain chain ) { - if (action.equals(FieldCapabilitiesAction.NAME)) { + if (action.equals(TransportFieldCapabilitiesAction.NAME)) { final Consumer actionWrapper = resp -> { try { fieldCaps.incrementAndGet(); diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java index c00d6d9a2f2e6..54a5a8821a2f9 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; @@ -234,7 +234,7 @@ private void testExpiredDeletion(Float customThrottle, int numUnusedState) throw String snapshotUpdate = "{ \"timestamp\": " + oneDayAgo + "}"; UpdateRequest updateSnapshotRequest = new UpdateRequest(".ml-anomalies-" + job.getId(), snapshotDocId); updateSnapshotRequest.doc(snapshotUpdate.getBytes(StandardCharsets.UTF_8), XContentType.JSON); - client().execute(UpdateAction.INSTANCE, updateSnapshotRequest).get(); + client().execute(TransportUpdateAction.TYPE, updateSnapshotRequest).get(); // Now let's create some forecasts openJob(job.getId()); diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotRetentionIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotRetentionIT.java index 8c29c30d1a2ea..37e41c5d8db3c 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotRetentionIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotRetentionIT.java @@ -11,8 +11,8 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.PlainActionFuture; @@ -239,7 +239,7 @@ private void persistModelSnapshotDoc(String jobId, String snapshotId, Date times modelSnapshotBuilder.build().toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS); indexRequest.source(xContentBuilder); - DocWriteResponse indexResponse = client().execute(IndexAction.INSTANCE, indexRequest).actionGet(); + DocWriteResponse indexResponse = client().execute(TransportIndexAction.TYPE, indexRequest).actionGet(); assertThat(indexResponse.getResult(), is(DocWriteResponse.Result.CREATED)); } diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotSearchIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotSearchIT.java index 2005c6d1fee0f..4b238393d50df 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotSearchIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/ModelSnapshotSearchIT.java @@ -11,8 +11,8 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.master.MasterNodeRequest; @@ -126,7 +126,7 @@ private void persistModelSnapshotDoc(String jobId, String snapshotId, Date times modelSnapshotBuilder.build().toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS); indexRequest.source(xContentBuilder); - DocWriteResponse indexResponse = client().execute(IndexAction.INSTANCE, indexRequest).actionGet(); + DocWriteResponse indexResponse = client().execute(TransportIndexAction.TYPE, indexRequest).actionGet(); assertThat(indexResponse.getResult(), is(DocWriteResponse.Result.CREATED)); } diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java index 1458b9ccf693c..7f0a4cc381ee2 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java @@ -7,8 +7,8 @@ package org.elasticsearch.xpack.ml.integration; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.common.bytes.BytesArray; @@ -108,7 +108,7 @@ public void testCluster_GivenAnomalyDetectionJobAndTrainedModelDeployment_Should try (XContentBuilder builder = JsonXContent.contentBuilder()) { modelDefinitionDoc.toXContent(builder, null); client().execute( - IndexAction.INSTANCE, + TransportIndexAction.TYPE, new IndexRequest(InferenceIndexConstants.nativeDefinitionStore()).source(builder) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) ).actionGet(); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java index e52a60691d150..d7c5f15fcaf47 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java @@ -9,8 +9,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; @@ -202,7 +202,7 @@ private void makeMlInternalIndicesHidden() { .map(aliasAction -> aliasAction.indices()[0] + ": " + String.join(",", aliasAction.aliases())) .collect(Collectors.joining("; ")); logger.debug("The following ML internal aliases will now be made hidden: [{}]", indicesWithNonHiddenAliasesString); - executeAsyncWithOrigin(client, ML_ORIGIN, IndicesAliasesAction.INSTANCE, indicesAliasesRequest, finalListener); + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndicesAliasesAction.TYPE, indicesAliasesRequest, finalListener); }, finalListener::onFailure); // Step 3: Once indices are hidden, fetch ML internal aliases to find out whether the aliases are hidden or not. diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java index d7a50b5f87f04..60993e12a2088 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarEventAction.java @@ -8,11 +8,11 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.WriteRequest; @@ -67,7 +67,7 @@ protected void doExecute(Task task, DeleteCalendarEventAction.Request request, A ActionListener calendarListener = ActionListener.wrap(calendar -> { GetRequest getRequest = new GetRequest(MlMetaIndex.indexName(), eventId); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, ActionListener.wrap(getResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, ActionListener.wrap(getResponse -> { if (getResponse.isExists() == false) { listener.onFailure(new ResourceNotFoundException("No event with id [" + eventId + "]")); return; @@ -115,7 +115,7 @@ private void deleteEvent(String eventId, Calendar calendar, ActionListener() { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportDeleteAction.TYPE, deleteRequest, new ActionListener() { @Override public void onResponse(DeleteResponse response) { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java index 80fabff58d101..6d183501d2043 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.AcknowledgedTransportMasterNodeAction; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; @@ -94,7 +94,7 @@ protected void masterOperation( executeAsyncWithOrigin( client, ML_ORIGIN, - UpdateAction.INSTANCE, + TransportUpdateAction.TYPE, updateRequest, ActionListener.wrap(updateResponse -> chainedListener.onResponse(null), chainedListener::onFailure) ); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPreviewDatafeedAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPreviewDatafeedAction.java index 5dd671962569a..9d28619ba1db6 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPreviewDatafeedAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPreviewDatafeedAction.java @@ -8,8 +8,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.client.internal.Client; @@ -197,7 +197,7 @@ private void isDateNanos(DatafeedConfig datafeed, String timeField, ActionListen datafeed.getHeaders(), ML_ORIGIN, client, - FieldCapabilitiesAction.INSTANCE, + TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, ActionListener.wrap(fieldCapsResponse -> { Map timeFieldCaps = fieldCapsResponse.getField(timeField); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutCalendarAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutCalendarAction.java index df8fd9c506924..119b1d2e9ab1b 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutCalendarAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutCalendarAction.java @@ -9,8 +9,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.WriteRequest; @@ -65,7 +65,7 @@ protected void doExecute(Task task, PutCalendarAction.Request request, ActionLis indexRequest.opType(DocWriteRequest.OpType.CREATE); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, new ActionListener<>() { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, new ActionListener<>() { @Override public void onResponse(DocWriteResponse indexResponse) { listener.onResponse(new PutCalendarAction.Response(calendar)); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutFilterAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutFilterAction.java index ea37661c7c08e..9237c23e537c1 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutFilterAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPutFilterAction.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.WriteRequest; @@ -59,7 +59,7 @@ protected void doExecute(Task task, PutFilterAction.Request request, ActionListe throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e); } - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, new ActionListener<>() { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, new ActionListener<>() { @Override public void onResponse(DocWriteResponse indexResponse) { listener.onResponse(new PutFilterAction.Response(filter)); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateFilterAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateFilterAction.java index 622d5ccab6940..c1e77d953ab54 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateFilterAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpdateFilterAction.java @@ -9,11 +9,11 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.action.support.WriteRequest; @@ -135,7 +135,7 @@ private void indexUpdatedFilter( throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e); } - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, new ActionListener<>() { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, new ActionListener<>() { @Override public void onResponse(DocWriteResponse indexResponse) { jobManager.notifyFilterChanged( @@ -164,7 +164,7 @@ public void onFailure(Exception e) { private void getFilterWithVersion(String filterId, ActionListener listener) { GetRequest getRequest = new GetRequest(MlMetaIndex.indexName(), MlFilter.documentId(filterId)); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, listener.delegateFailure((l, getDocResponse) -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, listener.delegateFailure((l, getDocResponse) -> { try { if (getDocResponse.isExists()) { BytesReference docSource = getDocResponse.getSourceAsBytesRef(); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java index 27838795aedd2..7d3a063e3435c 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java @@ -9,9 +9,9 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.query.QueryBuilder; @@ -152,7 +152,7 @@ public static void create( .toArray(String[]::new); fieldCapabilitiesRequest.fields(requestFields); ClientHelper.executeWithHeaders(datafeed.getHeaders(), ClientHelper.ML_ORIGIN, client, () -> { - client.execute(FieldCapabilitiesAction.INSTANCE, fieldCapabilitiesRequest, fieldCapabilitiesHandler); + client.execute(TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, fieldCapabilitiesHandler); // This response gets discarded - the listener handles the real response return null; }); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/persistence/DatafeedConfigProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/persistence/DatafeedConfigProvider.java index 211fd8743f49c..56c34aa590fb9 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/persistence/DatafeedConfigProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/persistence/DatafeedConfigProvider.java @@ -13,14 +13,14 @@ import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; @@ -138,7 +138,7 @@ public void putDatafeedConfig( executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, indexRequest, ActionListener.wrap(r -> listener.onResponse(Tuple.tuple(finalConfig, r)), e -> { if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { @@ -176,7 +176,7 @@ public void getDatafeedConfig( if (parentTaskId != null) { getRequest.setParentTask(parentTaskId); } - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, new ActionListener() { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, new ActionListener() { @Override public void onResponse(GetResponse getResponse) { if (getResponse.isExists() == false) { @@ -280,14 +280,20 @@ public void findDatafeedsByJobIds( public void deleteDatafeedConfig(String datafeedId, ActionListener actionListener) { DeleteRequest request = new DeleteRequest(MlConfigIndex.indexName(), DatafeedConfig.documentId(datafeedId)); request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - executeAsyncWithOrigin(client, ML_ORIGIN, DeleteAction.INSTANCE, request, actionListener.delegateFailure((l, deleteResponse) -> { - if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { - l.onFailure(ExceptionsHelper.missingDatafeedException(datafeedId)); - return; - } - assert deleteResponse.getResult() == DocWriteResponse.Result.DELETED; - l.onResponse(deleteResponse); - })); + executeAsyncWithOrigin( + client, + ML_ORIGIN, + TransportDeleteAction.TYPE, + request, + actionListener.delegateFailure((l, deleteResponse) -> { + if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { + l.onFailure(ExceptionsHelper.missingDatafeedException(datafeedId)); + return; + } + assert deleteResponse.getResult() == DocWriteResponse.Result.DELETED; + l.onResponse(deleteResponse); + }) + ); } /** @@ -314,42 +320,48 @@ public void updateDatefeedConfig( ) { GetRequest getRequest = new GetRequest(MlConfigIndex.indexName(), DatafeedConfig.documentId(datafeedId)); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, new DelegatingActionListener<>(updatedConfigListener) { - @Override - public void onResponse(GetResponse getResponse) { - if (getResponse.isExists() == false) { - delegate.onFailure(ExceptionsHelper.missingDatafeedException(datafeedId)); - return; - } - final long seqNo = getResponse.getSeqNo(); - final long primaryTerm = getResponse.getPrimaryTerm(); - BytesReference source = getResponse.getSourceAsBytesRef(); - DatafeedConfig.Builder configBuilder; - try { - configBuilder = parseLenientlyFromSource(source); - } catch (IOException e) { - delegate.onFailure(new ElasticsearchParseException("Failed to parse datafeed config [" + datafeedId + "]", e)); - return; - } + executeAsyncWithOrigin( + client, + ML_ORIGIN, + TransportGetAction.TYPE, + getRequest, + new DelegatingActionListener<>(updatedConfigListener) { + @Override + public void onResponse(GetResponse getResponse) { + if (getResponse.isExists() == false) { + delegate.onFailure(ExceptionsHelper.missingDatafeedException(datafeedId)); + return; + } + final long seqNo = getResponse.getSeqNo(); + final long primaryTerm = getResponse.getPrimaryTerm(); + BytesReference source = getResponse.getSourceAsBytesRef(); + DatafeedConfig.Builder configBuilder; + try { + configBuilder = parseLenientlyFromSource(source); + } catch (IOException e) { + delegate.onFailure(new ElasticsearchParseException("Failed to parse datafeed config [" + datafeedId + "]", e)); + return; + } - DatafeedConfig updatedConfig; - try { - updatedConfig = update.apply(configBuilder.build(), headers, clusterService.state()); - } catch (Exception e) { - delegate.onFailure(e); - return; - } + DatafeedConfig updatedConfig; + try { + updatedConfig = update.apply(configBuilder.build(), headers, clusterService.state()); + } catch (Exception e) { + delegate.onFailure(e); + return; + } - ActionListener validatedListener = ActionListener.wrap( - ok -> indexUpdatedConfig(updatedConfig, seqNo, primaryTerm, ActionListener.wrap(indexResponse -> { - assert indexResponse.getResult() == DocWriteResponse.Result.UPDATED; - delegate.onResponse(updatedConfig); - }, delegate::onFailure)), - delegate::onFailure - ); - validator.accept(updatedConfig, validatedListener); + ActionListener validatedListener = ActionListener.wrap( + ok -> indexUpdatedConfig(updatedConfig, seqNo, primaryTerm, ActionListener.wrap(indexResponse -> { + assert indexResponse.getResult() == DocWriteResponse.Result.UPDATED; + delegate.onResponse(updatedConfig); + }, delegate::onFailure)), + delegate::onFailure + ); + validator.accept(updatedConfig, validatedListener); + } } - }); + ); } private void indexUpdatedConfig(DatafeedConfig updatedConfig, long seqNo, long primaryTerm, ActionListener listener) { @@ -362,7 +374,7 @@ private void indexUpdatedConfig(DatafeedConfig updatedConfig, long seqNo, long p indexRequest.setIfSeqNo(seqNo); indexRequest.setIfPrimaryTerm(primaryTerm); - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, listener); + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, listener); } catch (IOException e) { listener.onFailure( diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTask.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTask.java index 7f50be8a663fe..1467bd6ca0530 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTask.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTask.java @@ -11,8 +11,8 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.TransportSearchAction; @@ -262,7 +262,7 @@ void persistProgress(Client clientToUse, String jobId, Runnable runnable) { storedProgress.get().toXContent(jsonBuilder, Payload.XContent.EMPTY_PARAMS); indexRequest.source(jsonBuilder); } - executeAsyncWithOrigin(clientToUse, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, indexProgressDocListener); + executeAsyncWithOrigin(clientToUse, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, indexProgressDocListener); }, e -> { LOGGER.error( () -> format("[%s] cannot persist progress as an error occurred while retrieving former progress document", jobId), diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java index 4798e699f46c4..8c6b78f41285c 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java @@ -18,9 +18,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.internal.Client; @@ -183,7 +183,7 @@ private static void getFieldCapsForRequiredFields( config.getHeaders(), ML_ORIGIN, client, - FieldCapabilitiesAction.INSTANCE, + TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, listener ); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetectorFactory.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetectorFactory.java index 9e925ff3f8fee..1d78ad22f3f85 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetectorFactory.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetectorFactory.java @@ -14,9 +14,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.TransportSearchAction; @@ -182,7 +182,7 @@ private void getFieldCaps(String[] index, DataFrameAnalyticsConfig config, Actio fieldCapabilitiesRequest.runtimeFields(config.getSource().getRuntimeMappings()); LOGGER.debug(() -> format("[%s] Requesting field caps for index %s", config.getId(), Arrays.toString(index))); ClientHelper.executeWithHeaders(config.getHeaders(), ML_ORIGIN, client, () -> { - client.execute(FieldCapabilitiesAction.INSTANCE, fieldCapabilitiesRequest, listener); + client.execute(TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, listener); // This response gets discarded - the listener handles the real response return null; }); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java index bbdd6167414a6..618cbc075bd99 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java @@ -13,11 +13,11 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.DocWriteRequest; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; @@ -139,7 +139,7 @@ private void exists(String jobId, ActionListener listener) { GetRequest getRequest = new GetRequest(MlConfigIndex.indexName(), DataFrameAnalyticsConfig.documentId(jobId)); getRequest.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, getListener); + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, getListener); } private void deleteLeftOverDocs(DataFrameAnalyticsConfig config, TimeValue timeout, ActionListener listener) { @@ -166,7 +166,7 @@ public void update( String id = update.getId(); GetRequest getRequest = new GetRequest(MlConfigIndex.indexName(), DataFrameAnalyticsConfig.documentId(id)); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, ActionListener.wrap(getResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, ActionListener.wrap(getResponse -> { // Fail the update request if the config to be updated doesn't exist if (getResponse.isExists() == false) { @@ -255,7 +255,7 @@ private void index( executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, indexRequest, ActionListener.wrap(indexResponse -> listener.onResponse(config), e -> { if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsDeleter.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsDeleter.java index 4ceb3b693cf89..843d9d74a1c7d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsDeleter.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsDeleter.java @@ -12,8 +12,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -107,7 +107,7 @@ private void deleteConfig(String id, ActionListener listen DeleteRequest deleteRequest = new DeleteRequest(MlConfigIndex.indexName()); deleteRequest.id(DataFrameAnalyticsConfig.documentId(id)); deleteRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - executeAsyncWithOrigin(client, ML_ORIGIN, DeleteAction.INSTANCE, deleteRequest, ActionListener.wrap(deleteResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportDeleteAction.TYPE, deleteRequest, ActionListener.wrap(deleteResponse -> { if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { listener.onFailure(ExceptionsHelper.missingDataFrameAnalytics(id)); return; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/steps/FinalStep.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/steps/FinalStep.java index 20791534b9801..7b27090dc302d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/steps/FinalStep.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/steps/FinalStep.java @@ -14,8 +14,8 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshAction; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.core.TimeValue; @@ -83,7 +83,7 @@ private void indexDataCounts(ActionListener listener) { IndexRequest indexRequest = new IndexRequest(MlStatsIndex.writeAlias()).id(DataCounts.documentId(config.getId())) .setRequireAlias(true) .source(builder); - executeAsyncWithOrigin(parentTaskClient(), ML_ORIGIN, IndexAction.INSTANCE, indexRequest, listener); + executeAsyncWithOrigin(parentTaskClient(), ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, listener); } catch (IOException e) { listener.onFailure(ExceptionsHelper.serverError("[{}] Error persisting final data counts", e, config.getId())); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProvider.java index cd2bbd92a741f..c10510c9eac57 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProvider.java @@ -21,8 +21,8 @@ import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.MultiSearchRequest; import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.search.SearchRequest; @@ -206,7 +206,7 @@ public void storeTrainedModelConfig(TrainedModelConfig trainedModelConfig, Actio executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, request, ActionListener.wrap(indexResponse -> listener.onResponse(true), e -> { if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { @@ -255,7 +255,7 @@ public void storeTrainedModelVocabulary( executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, createRequest(VocabularyConfig.docId(modelId), vocabularyConfig.getIndex(), vocabulary, allowOverwriting).setRefreshPolicy( WriteRequest.RefreshPolicy.IMMEDIATE ), @@ -303,7 +303,7 @@ public void storeTrainedModelDefinitionDoc( executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, createRequest(trainedModelDefinitionDoc.getDocId(), index, trainedModelDefinitionDoc, allowOverwriting), ActionListener.wrap(indexResponse -> listener.onResponse(null), e -> { if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { @@ -353,7 +353,7 @@ public void storeTrainedModelMetadata( executeAsyncWithOrigin( client, ML_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, createRequest( trainedModelMetadata.getDocId(), InferenceIndexConstants.LATEST_INDEX_NAME, diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobConfigProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobConfigProvider.java index 4c71f8fbce139..b77401f06f507 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobConfigProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobConfigProvider.java @@ -14,14 +14,14 @@ import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; @@ -127,14 +127,20 @@ public void putJob(Job job, ActionListener listener) { .opType(DocWriteRequest.OpType.CREATE) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, ActionListener.wrap(listener::onResponse, e -> { - if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { - // the job already exists - listener.onFailure(ExceptionsHelper.jobAlreadyExists(job.getId())); - } else { - listener.onFailure(e); - } - })); + executeAsyncWithOrigin( + client, + ML_ORIGIN, + TransportIndexAction.TYPE, + indexRequest, + ActionListener.wrap(listener::onResponse, e -> { + if (ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException) { + // the job already exists + listener.onFailure(ExceptionsHelper.jobAlreadyExists(job.getId())); + } else { + listener.onFailure(e); + } + }) + ); } catch (IOException e) { listener.onFailure(new ElasticsearchParseException("Failed to serialise job with id [" + job.getId() + "]", e)); @@ -196,16 +202,22 @@ public void deleteJob(String jobId, boolean errorIfMissing, ActionListener { - if (errorIfMissing) { - if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { - l.onFailure(ExceptionsHelper.missingJobException(jobId)); - return; + executeAsyncWithOrigin( + client, + ML_ORIGIN, + TransportDeleteAction.TYPE, + request, + actionListener.delegateFailure((l, deleteResponse) -> { + if (errorIfMissing) { + if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) { + l.onFailure(ExceptionsHelper.missingJobException(jobId)); + return; + } + assert deleteResponse.getResult() == DocWriteResponse.Result.DELETED; } - assert deleteResponse.getResult() == DocWriteResponse.Result.DELETED; - } - l.onResponse(deleteResponse); - })); + l.onResponse(deleteResponse); + }) + ); } /** @@ -223,7 +235,7 @@ public void deleteJob(String jobId, boolean errorIfMissing, ActionListener updatedJobListener) { GetRequest getRequest = new GetRequest(MlConfigIndex.indexName(), Job.documentId(jobId)); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, new DelegatingActionListener<>(updatedJobListener) { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, new DelegatingActionListener<>(updatedJobListener) { @Override public void onResponse(GetResponse getResponse) { if (getResponse.isExists() == false) { @@ -285,7 +297,7 @@ public void updateJobWithValidation( ) { GetRequest getRequest = new GetRequest(MlConfigIndex.indexName(), Job.documentId(jobId)); - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, ActionListener.wrap(getResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, ActionListener.wrap(getResponse -> { if (getResponse.isExists() == false) { listener.onFailure(ExceptionsHelper.missingJobException(jobId)); return; @@ -332,7 +344,7 @@ private void indexUpdatedJob(Job updatedJob, long seqNo, long primaryTerm, Actio indexRequest.setIfSeqNo(seqNo); indexRequest.setIfPrimaryTerm(primaryTerm); - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, indexRequest, ActionListener.wrap(indexResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, indexRequest, ActionListener.wrap(indexResponse -> { assert indexResponse.getResult() == DocWriteResponse.Result.UPDATED; updatedJobListener.onResponse(updatedJob); }, updatedJobListener::onFailure)); @@ -366,7 +378,7 @@ public void jobExists(String jobId, boolean errorIfMissing, @Nullable TaskId par getRequest.setParentTask(parentTaskId); } - executeAsyncWithOrigin(client, ML_ORIGIN, GetAction.INSTANCE, getRequest, ActionListener.wrap(getResponse -> { + executeAsyncWithOrigin(client, ML_ORIGIN, TransportGetAction.TYPE, getRequest, ActionListener.wrap(getResponse -> { if (getResponse.isExists() == false) { if (errorIfMissing) { listener.onFailure(ExceptionsHelper.missingJobException(jobId)); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataCountsPersister.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataCountsPersister.java index c3758aeda9b15..40951162045c3 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataCountsPersister.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataCountsPersister.java @@ -9,8 +9,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.xcontent.ToXContent; @@ -124,7 +124,7 @@ public void persistDataCountsAsync(String jobId, DataCounts counts, ActionListen .setRequireAlias(true) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .source(content); - executeAsyncWithOrigin(client, ML_ORIGIN, IndexAction.INSTANCE, request, listener.safeMap(r -> true)); + executeAsyncWithOrigin(client, ML_ORIGIN, TransportIndexAction.TYPE, request, listener.safeMap(r -> true)); } catch (IOException ioe) { String msg = "[" + jobId + "] Failed writing data_counts stats"; logger.error(msg, ioe); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionActionTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionActionTests.java index 1c0243fcab098..25d9a9570c7c4 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionActionTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionActionTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -59,7 +59,7 @@ private void setupMocks() { ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; listener.onResponse(null); return null; - }).when(client).execute(eq(UpdateAction.INSTANCE), any(), any()); + }).when(client).execute(eq(TransportUpdateAction.TYPE), any(), any()); when(client.threadPool()).thenReturn(threadPool); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); @@ -76,7 +76,7 @@ public void testOperation() { action.masterOperation(null, request, clusterState, ActionTestUtils.assertNoFailureListener(ack::set)); assertTrue(ack.get().isAcknowledged()); - verify(client, times(2)).execute(eq(UpdateAction.INSTANCE), any(), any()); + verify(client, times(2)).execute(eq(TransportUpdateAction.TYPE), any(), any()); verify(clusterService, never()).submitUnbatchedStateUpdateTask(any(), any()); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java index 680f7a2964f3d..4a7109f39df54 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/DataExtractorFactoryTests.java @@ -8,8 +8,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.settings.Settings; @@ -94,7 +94,7 @@ public void setUpTests() { ActionListener listener = (ActionListener) invocationMock.getArguments()[2]; listener.onResponse(fieldsCapabilities); return null; - }).when(client).execute(same(FieldCapabilitiesAction.INSTANCE), any(), any()); + }).when(client).execute(same(TransportFieldCapabilitiesAction.TYPE), any(), any()); doAnswer(invocationMock -> { ActionListener listener = (ActionListener) invocationMock.getArguments()[2]; diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTaskTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTaskTests.java index 70bacebd3609f..63afc4ef6659c 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTaskTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTaskTests.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.ml.dataframe; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.client.internal.Client; @@ -191,7 +191,7 @@ private void testPersistProgress(SearchHits searchHits, String expectedIndexOrAl doAnswer(withResponse(searchResponse)).when(client).execute(eq(TransportSearchAction.TYPE), any(), any()); IndexResponse indexResponse = mock(IndexResponse.class); - doAnswer(withResponse(indexResponse)).when(client).execute(eq(IndexAction.INSTANCE), any(), any()); + doAnswer(withResponse(indexResponse)).when(client).execute(eq(TransportIndexAction.TYPE), any(), any()); TaskManager taskManager = mock(TaskManager.class); @@ -218,7 +218,7 @@ private void testPersistProgress(SearchHits searchHits, String expectedIndexOrAl InOrder inOrder = inOrder(client, runnable); inOrder.verify(client).execute(eq(TransportSearchAction.TYPE), any(), any()); - inOrder.verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + inOrder.verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); inOrder.verify(runnable).run(); inOrder.verifyNoMoreInteractions(); @@ -287,7 +287,7 @@ private void testSetFailed(boolean nodeShuttingDown) throws IOException { doAnswer(withResponse(searchResponse)).when(client).execute(eq(TransportSearchAction.TYPE), any(), any()); IndexResponse indexResponse = mock(IndexResponse.class); - doAnswer(withResponse(indexResponse)).when(client).execute(eq(IndexAction.INSTANCE), any(), any()); + doAnswer(withResponse(indexResponse)).when(client).execute(eq(TransportIndexAction.TYPE), any(), any()); DataFrameAnalyticsTask task = new DataFrameAnalyticsTask( 123, @@ -316,7 +316,7 @@ private void testSetFailed(boolean nodeShuttingDown) throws IOException { // Verify progress was persisted ArgumentCaptor indexRequestCaptor = ArgumentCaptor.forClass(IndexRequest.class); verify(client).execute(eq(TransportSearchAction.TYPE), any(), any()); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); IndexRequest indexRequest = indexRequestCaptor.getValue(); assertThat(indexRequest.index(), equalTo(AnomalyDetectorsIndex.jobStateIndexWriteAlias())); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java index 9ec0540569689..d90696761e668 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java @@ -20,9 +20,9 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.fieldcaps.FieldCapabilities; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -293,7 +293,7 @@ private Map testCreateDestinationIndex(DataFrameAnalysis analysi }); doAnswer(callListenerOnResponse(fieldCapabilitiesResponse)).when(client) - .execute(eq(FieldCapabilitiesAction.INSTANCE), fieldCapabilitiesRequestCaptor.capture(), any()); + .execute(eq(TransportFieldCapabilitiesAction.TYPE), fieldCapabilitiesRequestCaptor.capture(), any()); String errorMessage = ""; switch (expectedError) { @@ -627,7 +627,7 @@ private Map testUpdateMappingsToDestIndex(DataFrameAnalysis anal }); doAnswer(callListenerOnResponse(fieldCapabilitiesResponse)).when(client) - .execute(eq(FieldCapabilitiesAction.INSTANCE), fieldCapabilitiesRequestCaptor.capture(), any()); + .execute(eq(TransportFieldCapabilitiesAction.TYPE), fieldCapabilitiesRequestCaptor.capture(), any()); DestinationIndex.updateMappingsToDestIndex( client, @@ -637,7 +637,7 @@ private Map testUpdateMappingsToDestIndex(DataFrameAnalysis anal ); verify(client, atLeastOnce()).threadPool(); - verify(client, atMost(1)).execute(eq(FieldCapabilitiesAction.INSTANCE), any(), any()); + verify(client, atMost(1)).execute(eq(TransportFieldCapabilitiesAction.TYPE), any(), any()); verify(client).execute(eq(PutMappingAction.INSTANCE), any(), any()); verifyNoMoreInteractions(client); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProviderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProviderTests.java index 164d4efe6b6f5..24b575b8f89be 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProviderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProviderTests.java @@ -10,8 +10,8 @@ import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.bytes.BytesArray; @@ -542,7 +542,7 @@ private Client createMockClient(ThreadPool threadPool) { private void assertThatIndexRequestHasOperation(Client client, DocWriteRequest.OpType operation) { var indexRequestArg = ArgumentCaptor.forClass(IndexRequest.class); - verify(client).execute(eq(IndexAction.INSTANCE), indexRequestArg.capture(), any()); + verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestArg.capture(), any()); assertThat(indexRequestArg.getValue().opType(), Matchers.is(operation)); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java index 352aa16c670f3..8cf5425d1d1de 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java @@ -11,9 +11,9 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.ActionTestUtils; @@ -375,7 +375,7 @@ private void testPersistQuantilesAsync(SearchHits searchHits, String expectedInd doAnswer(withResponse(searchResponse)).when(client).execute(eq(TransportSearchAction.TYPE), any(), any()); IndexResponse indexResponse = mock(IndexResponse.class); - doAnswer(withResponse(indexResponse)).when(client).execute(eq(IndexAction.INSTANCE), any(), any()); + doAnswer(withResponse(indexResponse)).when(client).execute(eq(TransportIndexAction.TYPE), any(), any()); Quantiles quantiles = new Quantiles("foo", new Date(), "bar"); ActionListener indexResponseListener = mock(ActionListener.class); @@ -383,7 +383,7 @@ private void testPersistQuantilesAsync(SearchHits searchHits, String expectedInd InOrder inOrder = inOrder(client, indexResponseListener); inOrder.verify(client).execute(eq(TransportSearchAction.TYPE), any(), any()); - inOrder.verify(client).execute(eq(IndexAction.INSTANCE), indexRequestCaptor.capture(), any()); + inOrder.verify(client).execute(eq(TransportIndexAction.TYPE), indexRequestCaptor.capture(), any()); inOrder.verify(indexResponseListener).onResponse(any()); inOrder.verifyNoMoreInteractions(); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java index 7322d315302d2..bde774686b84c 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionType; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.support.ActionTestUtils; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.internal.Client; @@ -165,6 +166,13 @@ public void setup() throws Exception { doAnswer(invocationOnMock -> { if (invocationOnMock.getArguments()[0] instanceof ActionType v) { ActionListener l = (ActionListener) invocationOnMock.getArguments()[2]; + if (v == TransportClusterHealthAction.TYPE) { + ActionListener listener = (ActionListener) l; + listener.onResponse( + new ClusterHealthResponse("test", new String[0], ClusterState.EMPTY_STATE, 0, 0, 0, TimeValue.ZERO) + ); + return null; + } ParameterizedType parameterizedType = (ParameterizedType) v.getClass().getGenericSuperclass(); Type t = parameterizedType.getActualTypeArguments()[0]; if (t.getTypeName().contains("AcknowledgedResponse")) { @@ -172,13 +180,6 @@ public void setup() throws Exception { listener.onResponse(AcknowledgedResponse.TRUE); return null; } - if (t.getTypeName().contains("ClusterHealthResponse")) { - ActionListener listener = (ActionListener) l; - listener.onResponse( - new ClusterHealthResponse("test", new String[0], ClusterState.EMPTY_STATE, 0, 0, 0, TimeValue.ZERO) - ); - return null; - } fail("Mock not configured to handle generic type " + t.getTypeName()); } return null; diff --git a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/BlobStoreCacheServiceTests.java b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/BlobStoreCacheServiceTests.java index b5e476ecbf25f..8083d3c729ba3 100644 --- a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/BlobStoreCacheServiceTests.java +++ b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/BlobStoreCacheServiceTests.java @@ -8,12 +8,12 @@ package org.elasticsearch.xpack.searchablesnapshots.cache.blob; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.blobcache.common.ByteRange; import org.elasticsearch.client.internal.Client; @@ -98,7 +98,7 @@ public void testGetWhenServiceNotStarted() { ) ); return null; - }).when(mockClient).execute(eq(GetAction.INSTANCE), any(GetRequest.class), any(ActionListener.class)); + }).when(mockClient).execute(eq(TransportGetAction.TYPE), any(GetRequest.class), any(ActionListener.class)); BlobStoreCacheService blobCacheService = new BlobStoreCacheService(null, mockClient, SNAPSHOT_BLOB_CACHE_INDEX); blobCacheService.start(); @@ -130,7 +130,7 @@ public void testPutWhenServiceNotStarted() { ) ); return null; - }).when(mockClient).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); + }).when(mockClient).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), any(ActionListener.class)); BlobStoreCacheService blobCacheService = new BlobStoreCacheService(null, mockClient, SNAPSHOT_BLOB_CACHE_INDEX); blobCacheService.start(); @@ -168,7 +168,7 @@ public void testWaitForInFlightCacheFillsToComplete() throws Exception { ) ); return null; - }).when(mockClient).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); + }).when(mockClient).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), any(ActionListener.class)); final BlobStoreCacheService blobCacheService = new BlobStoreCacheService(null, mockClient, SNAPSHOT_BLOB_CACHE_INDEX); blobCacheService.start(); diff --git a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityFcActionAuthorizationIT.java b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityFcActionAuthorizationIT.java index a0b4222478e59..8b54bd060fa19 100644 --- a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityFcActionAuthorizationIT.java +++ b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityFcActionAuthorizationIT.java @@ -10,9 +10,9 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.TransportVersion; import org.elasticsearch.action.admin.cluster.remote.RemoteClusterNodesAction; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.client.internal.Client; @@ -344,7 +344,7 @@ public void testUpdateCrossClusterApiKey() throws IOException { "node", threadPool, (String) crossClusterApiKeyMap.get("encoded"), - Map.of(FieldCapabilitiesAction.NAME, crossClusterAccessSubjectInfo) + Map.of(TransportFieldCapabilitiesAction.NAME, crossClusterAccessSubjectInfo) ) ) { final RemoteClusterService remoteClusterService = service.getRemoteClusterService(); @@ -360,7 +360,7 @@ public void testUpdateCrossClusterApiKey() throws IOException { // 1. Not accessible because API key does not grant the access final ElasticsearchSecurityException e1 = expectThrows( ElasticsearchSecurityException.class, - () -> remoteClusterClient.execute(FieldCapabilitiesAction.INSTANCE, request).actionGet() + () -> remoteClusterClient.execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet() ); assertThat( e1.getMessage(), @@ -387,7 +387,7 @@ public void testUpdateCrossClusterApiKey() throws IOException { }"""); assertOK(performRequestWithAdminUser(adminClient(), updateApiKeyRequest)); final FieldCapabilitiesResponse fieldCapabilitiesResponse = remoteClusterClient.execute( - FieldCapabilitiesAction.INSTANCE, + TransportFieldCapabilitiesAction.TYPE, request ).actionGet(); assertThat(fieldCapabilitiesResponse.getIndices(), arrayContaining("index")); @@ -407,7 +407,7 @@ public void testUpdateCrossClusterApiKey() throws IOException { assertOK(performRequestWithAdminUser(adminClient(), updateApiKeyRequest)); final ElasticsearchSecurityException e2 = expectThrows( ElasticsearchSecurityException.class, - () -> remoteClusterClient.execute(FieldCapabilitiesAction.INSTANCE, request).actionGet() + () -> remoteClusterClient.execute(TransportFieldCapabilitiesAction.TYPE, request).actionGet() ); assertThat( e2.getMessage(), diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java index 0b50b7cdfe78e..daea0e38c2c40 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; @@ -125,7 +125,7 @@ public void testSecurityFeatureStateSnapshotAndRestore() throws Exception { assertThat(exception.getResponse().getStatusLine().getStatusCode(), equalTo(403)); assertThat( exception.getMessage(), - containsString("action [" + IndexAction.NAME + "] is unauthorized for user [" + LOCAL_TEST_USER_NAME + "]") + containsString("action [" + TransportIndexAction.NAME + "] is unauthorized for user [" + LOCAL_TEST_USER_NAME + "]") ); client().admin().indices().prepareClose("test_index").get(); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java index 673956199677b..72a6b6049932c 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java @@ -16,8 +16,8 @@ import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.Request; @@ -2834,7 +2834,7 @@ private void expectRoleDescriptorsForApiKey( } private Map getApiKeyDocument(String apiKeyId) { - return client().execute(GetAction.INSTANCE, new GetRequest(SECURITY_MAIN_ALIAS, apiKeyId)).actionGet().getSource(); + return client().execute(TransportGetAction.TYPE, new GetRequest(SECURITY_MAIN_ALIAS, apiKeyId)).actionGet().getSource(); } private ApiKey getApiKeyInfo(Client client, String apiKeyId, boolean withLimitedBy, boolean useGetApiKey) { diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/apikey/ApiKeySingleNodeTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/apikey/ApiKeySingleNodeTests.java index 9b1350a43f9a2..91884086af959 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/apikey/ApiKeySingleNodeTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/apikey/ApiKeySingleNodeTests.java @@ -9,15 +9,15 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchStatusException; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; import org.elasticsearch.action.admin.cluster.node.info.TransportNodesInfoAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.ingest.GetPipelineAction; import org.elasticsearch.action.ingest.GetPipelineRequest; import org.elasticsearch.action.support.PlainActionFuture; @@ -314,7 +314,7 @@ public void testGrantApiKeyForUserWithRunAs() throws IOException { assertThat(securityClient.getApiKey(apiKeyId).getUsername(), equalTo("user2")); final Client clientWithGrantedKey = client().filterWithHeader(Map.of("Authorization", "ApiKey " + base64ApiKeyKeyValue)); // The API key has privileges (inherited from user2) to check cluster health - clientWithGrantedKey.execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest()).actionGet(); + clientWithGrantedKey.execute(TransportClusterHealthAction.TYPE, new ClusterHealthRequest()).actionGet(); // If the API key is granted with limiting descriptors, it should not be able to read pipeline if (grantApiKeyRequest.getApiKeyRequest().getRoleDescriptors().isEmpty()) { clientWithGrantedKey.execute(GetPipelineAction.INSTANCE, new GetPipelineRequest()).actionGet(); @@ -575,7 +575,7 @@ public void testCreateCrossClusterApiKey() throws IOException { ); // Check the API key attributes with raw document - final Map document = client().execute(GetAction.INSTANCE, new GetRequest(SECURITY_MAIN_ALIAS, apiKeyId)) + final Map document = client().execute(TransportGetAction.TYPE, new GetRequest(SECURITY_MAIN_ALIAS, apiKeyId)) .actionGet() .getSource(); assertThat(document.get("type"), equalTo("cross_cluster")); @@ -804,7 +804,7 @@ private GrantApiKeyRequest buildGrantApiKeyRequest(String username, SecureString } private Map getApiKeyDocument(String apiKeyId) { - final GetResponse getResponse = client().execute(GetAction.INSTANCE, new GetRequest(".security-7", apiKeyId)).actionGet(); + final GetResponse getResponse = client().execute(TransportGetAction.TYPE, new GetRequest(".security-7", apiKeyId)).actionGet(); return getResponse.getSource(); } } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java index f7bc8a1770981..7a0cb604f4ce9 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java @@ -7,8 +7,8 @@ package org.elasticsearch.xpack.security.authz; import org.elasticsearch.action.admin.indices.alias.Alias; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; @@ -133,13 +133,13 @@ public void testCreateIndexThenAliasesCreateOnlyPermission() { assertThrowsAuthorizationException( client.admin().indices().prepareAliases().addAlias("test_1", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); assertThrowsAuthorizationException( client.admin().indices().prepareAliases().addAlias("test_*", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); } @@ -154,7 +154,7 @@ public void testCreateIndexAndAliasesCreateOnlyPermission() { assertThrowsAuthorizationException( client(headers).admin().indices().prepareCreate("test_1").addAlias(new Alias("test_2"))::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); } @@ -169,19 +169,19 @@ public void testDeleteAliasesCreateOnlyPermission() { assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "alias_1")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "alias_*")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "_all")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_only" ); } @@ -308,7 +308,7 @@ public void testCreateIndexThenAliasesCreateAndAliasesPermission() { // fails: user doesn't have manage_aliases on alias_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().addAlias("test_1", "alias_1").addAlias("test_1", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_test" ); } @@ -328,7 +328,7 @@ public void testCreateIndexAndAliasesCreateAndAliasesPermission() { // fails: user doesn't have manage_aliases on alias_1 assertThrowsAuthorizationException( client.admin().indices().prepareCreate("test_2").addAlias(new Alias("test_alias")).addAlias(new Alias("alias_2"))::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_test" ); } @@ -386,14 +386,14 @@ public void testDeleteAliasesCreateAndAliasesPermission() { // fails: user doesn't have manage_aliases on alias_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "alias_1")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_test" ); // fails: user doesn't have manage_aliases on alias_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", new String[] { "_all", "alias_1" })::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_test" ); @@ -471,14 +471,14 @@ public void testCreateIndexThenAliasesCreateAndAliasesPermission2() { // fails: user doesn't have manage_aliases aliases on test_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().addAlias("test_1", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_alias" ); // fails: user doesn't have manage_aliases aliases on test_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().addAlias("test_1", "alias_1")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_alias" ); @@ -503,7 +503,7 @@ public void testCreateIndexAndAliasesCreateAndAliasesPermission2() { // fails: user doesn't have manage_aliases on test_1, create index is rejected as a whole assertThrowsAuthorizationException( client.admin().indices().prepareCreate("test_1").addAlias(new Alias("test_alias"))::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_alias" ); } @@ -521,7 +521,7 @@ public void testDeleteAliasesCreateAndAliasesPermission2() { // fails: user doesn't have manage_aliases on test_1 assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_alias" ); @@ -642,7 +642,7 @@ public void testDeleteAliasesCreateAndAliasesPermission3() { // fails: user doesn't have manage_aliases privilege on non_authorized assertThrowsAuthorizationException( client.admin().indices().prepareAliases().removeAlias("test_1", "non_authorized").removeAlias("test_1", "test_alias")::get, - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "create_test_aliases_test_alias" ); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java index a5399e3699bb8..7e5fd3a8717e2 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.security.authz; import org.elasticsearch.ElasticsearchSecurityException; -import org.elasticsearch.action.get.GetAction; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.MultiGetResponse; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -351,9 +351,9 @@ public void testGet() { client().prepareGet("test1", "id").get(); - assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("index1", "id")::get, GetAction.NAME); + assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("index1", "id")::get, TransportGetAction.TYPE.name()); - assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("missing", "id")::get, GetAction.NAME); + assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("missing", "id")::get, TransportGetAction.TYPE.name()); expectThrows(IndexNotFoundException.class, () -> client().prepareGet("test5", "id").get()); } @@ -374,7 +374,7 @@ public void testMultiGet() { assertEquals("index1", multiGetResponse.getResponses()[1].getFailure().getIndex()); assertAuthorizationExceptionDefaultUsers( multiGetResponse.getResponses()[1].getFailure().getFailure(), - MultiGetAction.NAME + "[shard]" + TransportMultiGetAction.NAME + "[shard]" ); assertFalse(multiGetResponse.getResponses()[2].isFailed()); assertEquals("test3", multiGetResponse.getResponses()[2].getResponse().getIndex()); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java index 74907bf48794a..6f1554a988f83 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.internal.Requests; import org.elasticsearch.core.Strings; @@ -89,7 +89,7 @@ public void testUpdate() { assertThrowsAuthorizationExceptionDefaultUsers( client().prepareUpdate("index1", "id").setDoc(Requests.INDEX_CONTENT_TYPE, "field2", "value2")::get, - UpdateAction.NAME + TransportUpdateAction.NAME ); expectThrows( @@ -99,7 +99,7 @@ public void testUpdate() { assertThrowsAuthorizationExceptionDefaultUsers( client().prepareUpdate("missing", "id").setDoc(Requests.INDEX_CONTENT_TYPE, "field2", "value2")::get, - UpdateAction.NAME + TransportUpdateAction.NAME ); ensureGreen(); } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java index 85b33b2ead61a..1a05807d158b0 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/user/AnonymousUserIntegTests.java @@ -9,9 +9,9 @@ import org.apache.http.Header; import org.apache.http.util.EntityUtils; import org.elasticsearch.ElasticsearchStatusException; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; @@ -169,7 +169,7 @@ public void testGrantApiKeyForAnonymousUserTokenWithRunAsWillFail() throws IOExc } private Map getApiKeyDocument(String apiKeyId) { - final GetResponse getResponse = client().execute(GetAction.INSTANCE, new GetRequest(".security-7", apiKeyId)).actionGet(); + final GetResponse getResponse = client().execute(TransportGetAction.TYPE, new GetRequest(".security-7", apiKeyId)).actionGet(); return getResponse.getSource(); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java index bd951dc760b2c..997f58a01c0e1 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilter.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.IndicesRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.ActionFilter; @@ -131,7 +131,7 @@ private void ap Request request, ActionListener listener ) { - if (CloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { + if (TransportCloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { IndicesRequest indicesRequest = (IndicesRequest) request; try { destructiveOperations.failDestructive(indicesRequest.indices()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index a898c19c13658..18397bed2426d 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -27,8 +27,8 @@ import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.ContextPreservingActionListener; @@ -438,7 +438,7 @@ private void createOAuth2Tokens( () -> executeAsyncWithOrigin( client, SECURITY_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, indexTokenRequest, ActionListener.wrap(indexResponse -> { if (indexResponse.getResult() == Result.CREATED) { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/IndexServiceAccountTokenStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/IndexServiceAccountTokenStore.java index 1df40b1d88ce5..92c0998f38fd4 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/IndexServiceAccountTokenStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/IndexServiceAccountTokenStore.java @@ -17,11 +17,11 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.TransportBulkAction; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequest; @@ -108,7 +108,7 @@ void doAuthenticate(ServiceAccountToken token, ActionListener executeAsyncWithOrigin( client, SECURITY_ORIGIN, - GetAction.INSTANCE, + TransportGetAction.TYPE, getRequest, ActionListener.wrap(response -> { if (response.isExists()) { @@ -228,7 +228,7 @@ void deleteToken(DeleteServiceAccountTokenRequest request, ActionListener { final ClearSecurityCacheRequest clearSecurityCacheRequest = new ClearSecurityCacheRequest().cacheName( diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java index 142490aa90331..8a0a9c09b7d1a 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java @@ -16,18 +16,18 @@ import org.elasticsearch.action.DelegatingActionListener; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.admin.indices.alias.Alias; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.bulk.BulkItemRequest; import org.elasticsearch.action.bulk.BulkShardRequest; import org.elasticsearch.action.bulk.TransportShardBulkAction; import org.elasticsearch.action.datastreams.CreateDataStreamAction; import org.elasticsearch.action.datastreams.MigrateToDataStreamAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.GroupedActionListener; import org.elasticsearch.action.support.replication.TransportReplicationAction.ConcreteShardRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; @@ -115,8 +115,8 @@ public class AuthorizationService { PRINCIPAL_ROLES_FIELD_NAME, new String[] { SystemUser.ROLE_NAME } ); - private static final String IMPLIED_INDEX_ACTION = IndexAction.NAME + ":op_type/index"; - private static final String IMPLIED_CREATE_ACTION = IndexAction.NAME + ":op_type/create"; + private static final String IMPLIED_INDEX_ACTION = TransportIndexAction.NAME + ":op_type/index"; + private static final String IMPLIED_CREATE_ACTION = TransportIndexAction.NAME + ":op_type/create"; private static final Logger logger = LogManager.getLogger(AuthorizationService.class); @@ -557,7 +557,12 @@ private void handleIndexActionAuthorizationResult( runRequestInterceptors(requestInfo, authzInfo, authorizationEngine, listener); } else { Set aliases = ((CreateIndexRequest) request).aliases(); - final RequestInfo aliasesRequestInfo = new RequestInfo(authentication, request, IndicesAliasesAction.NAME, authzContext); + final RequestInfo aliasesRequestInfo = new RequestInfo( + authentication, + request, + TransportIndicesAliasesAction.NAME, + authzContext + ); authzEngine.authorizeIndexAction( aliasesRequestInfo, authzInfo, @@ -903,8 +908,8 @@ private static String getAction(BulkItemRequest item) { return switch (docWriteRequest.opType()) { case INDEX -> IMPLIED_INDEX_ACTION; case CREATE -> IMPLIED_CREATE_ACTION; - case UPDATE -> UpdateAction.NAME; - case DELETE -> DeleteAction.NAME; + case UPDATE -> TransportUpdateAction.NAME; + case DELETE -> TransportDeleteAction.NAME; }; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java index cdbb690098cbe..1c1fed5540248 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/RBACEngine.java @@ -21,9 +21,9 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkShardRequest; import org.elasticsearch.action.bulk.SimulateBulkAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.get.MultiGetAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.get.TransportMultiGetAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchScrollRequest; import org.elasticsearch.action.search.SearchTransportService; import org.elasticsearch.action.search.TransportClearScrollAction; @@ -118,10 +118,10 @@ public class RBACEngine implements AuthorizationEngine { GetUserPrivilegesAction.NAME, GetApiKeyAction.NAME ); - private static final String INDEX_SUB_REQUEST_PRIMARY = IndexAction.NAME + "[p]"; - private static final String INDEX_SUB_REQUEST_REPLICA = IndexAction.NAME + "[r]"; - private static final String DELETE_SUB_REQUEST_PRIMARY = DeleteAction.NAME + "[p]"; - private static final String DELETE_SUB_REQUEST_REPLICA = DeleteAction.NAME + "[r]"; + private static final String INDEX_SUB_REQUEST_PRIMARY = TransportIndexAction.NAME + "[p]"; + private static final String INDEX_SUB_REQUEST_REPLICA = TransportIndexAction.NAME + "[r]"; + private static final String DELETE_SUB_REQUEST_PRIMARY = TransportDeleteAction.NAME + "[p]"; + private static final String DELETE_SUB_REQUEST_REPLICA = TransportDeleteAction.NAME + "[r]"; private static final Logger logger = LogManager.getLogger(RBACEngine.class); private final Settings settings; @@ -253,13 +253,13 @@ private static boolean shouldAuthorizeIndexActionNameOnly(String action, Transpo switch (action) { case BulkAction.NAME: case SimulateBulkAction.NAME: - case IndexAction.NAME: - case DeleteAction.NAME: + case TransportIndexAction.NAME: + case TransportDeleteAction.NAME: case INDEX_SUB_REQUEST_PRIMARY: case INDEX_SUB_REQUEST_REPLICA: case DELETE_SUB_REQUEST_PRIMARY: case DELETE_SUB_REQUEST_REPLICA: - case MultiGetAction.NAME: + case TransportMultiGetAction.NAME: case MultiTermVectorsAction.NAME: case TransportMultiSearchAction.NAME: case "indices:data/read/mpercolate": diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java index c795c021c8c75..7667a10538aca 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java @@ -20,9 +20,9 @@ import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.TransportBulkAction; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.MultiSearchRequest; import org.elasticsearch.action.search.MultiSearchResponse; @@ -31,7 +31,7 @@ import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.action.update.UpdateResponse; @@ -451,20 +451,26 @@ private void getVersionedDocument(String uid, ActionListener final GetRequest getRequest = new GetRequest(SECURITY_PROFILE_ALIAS, uidToDocId(uid)); frozenProfileIndex.checkIndexVersionThenExecute( listener::onFailure, - () -> executeAsyncWithOrigin(client, getActionOrigin(), GetAction.INSTANCE, getRequest, ActionListener.wrap(response -> { - if (false == response.isExists()) { - logger.debug("profile with uid [{}] does not exist", uid); - listener.onResponse(null); - return; - } - listener.onResponse( - new VersionedDocument( - buildProfileDocument(response.getSourceAsBytesRef()), - response.getPrimaryTerm(), - response.getSeqNo() - ) - ); - }, listener::onFailure)) + () -> executeAsyncWithOrigin( + client, + getActionOrigin(), + TransportGetAction.TYPE, + getRequest, + ActionListener.wrap(response -> { + if (false == response.isExists()) { + logger.debug("profile with uid [{}] does not exist", uid); + listener.onResponse(null); + return; + } + listener.onResponse( + new VersionedDocument( + buildProfileDocument(response.getSourceAsBytesRef()), + response.getPrimaryTerm(), + response.getSeqNo() + ) + ); + }, listener::onFailure) + ) ); }); } @@ -946,7 +952,7 @@ void doUpdate(UpdateRequest updateRequest, ActionListener listen () -> executeAsyncWithOrigin( client, getActionOrigin(), - UpdateAction.INSTANCE, + TransportUpdateAction.TYPE, updateRequest, ActionListener.wrap(updateResponse -> { assert updateResponse.getResult() == DocWriteResponse.Result.UPDATED diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java index bfd87326d4481..a7a0efbbf4aac 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/ServerTransportFilter.java @@ -11,7 +11,7 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.IndicesRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.DestructiveOperations; @@ -67,7 +67,7 @@ class ServerTransportFilter { * be sent back to the sender. */ void inbound(String action, TransportRequest request, TransportChannel transportChannel, ActionListener listener) { - if (CloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { + if (TransportCloseIndexAction.NAME.equals(action) || OpenIndexAction.NAME.equals(action) || DeleteIndexAction.NAME.equals(action)) { IndicesRequest indicesRequest = (IndicesRequest) request; try { destructiveOperations.failDestructive(indicesRequest.indices()); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java index fc56061a98883..721df8867c96a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/filter/SecurityActionFilterTests.java @@ -12,7 +12,7 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.MockIndicesRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.support.ActionFilterChain; @@ -229,7 +229,7 @@ public void testApplyDestructiveOperations() throws Exception { IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), randomFrom("*", "_all", "test*") ); - String action = randomFrom(CloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); + String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); ActionListener listener = mock(ActionListener.class); Task task = mock(Task.class); User user = new User("username", "r1", "r2"); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java index d29f4c78d6334..66cda4b3a653d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java @@ -14,10 +14,10 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.get.GetRequestBuilder; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateRequest; @@ -150,7 +150,7 @@ public void setup() throws Exception { final IndexResponse response = new IndexResponse(new ShardId("test", "test", 0), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), anyActionListener()); doAnswer(invocationOnMock -> { BulkRequest bulkRequest = (BulkRequest) invocationOnMock.getArguments()[0]; @SuppressWarnings("unchecked") diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java index 3958c8d629b4d..f4129a92942a0 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java @@ -21,9 +21,9 @@ import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.ClearScrollRequest; import org.elasticsearch.action.search.ClearScrollResponse; import org.elasticsearch.action.search.SearchRequest; @@ -168,7 +168,7 @@ protected void Request request, ActionListener listener ) { - if (IndexAction.NAME.equals(action.name())) { + if (TransportIndexAction.NAME.equals(action.name())) { assertThat(request, instanceOf(IndexRequest.class)); IndexRequest indexRequest = (IndexRequest) request; indexRequests.add(indexRequest); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java index b75d9ae782761..c40d48590f12b 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java @@ -17,10 +17,10 @@ import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateRequest; @@ -181,7 +181,7 @@ public void setup() throws Exception { final IndexResponse response = new IndexResponse(new ShardId("test", "test", 0), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), any(ActionListener.class)); doAnswer(invocationOnMock -> { BulkRequest bulkRequest = (BulkRequest) invocationOnMock.getArguments()[0]; ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java index 08fd03d1ac115..8d85b5eb57797 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java @@ -16,10 +16,10 @@ import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateRequestBuilder; @@ -143,7 +143,7 @@ public void setupClient() { ) ); return null; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), anyActionListener()); securityContext = new SecurityContext(Settings.EMPTY, threadPool.getThreadContext()); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java index b5d728d4a3c09..86845a2c07a26 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/HasPrivilegesRequestBuilderTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.action.user; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.bytes.BytesArray; @@ -94,14 +94,14 @@ public void testParseValidJsonWithJustIndexPrivileges() throws Exception { public void testParseValidJsonWithJustClusterPrivileges() throws Exception { String json = Strings.format(""" - { "cluster": [ "manage","%s","%s"] }""", ClusterHealthAction.NAME, ClusterStatsAction.NAME); + { "cluster": [ "manage","%s","%s"] }""", TransportClusterHealthAction.NAME, ClusterStatsAction.NAME); final HasPrivilegesRequestBuilder builder = new HasPrivilegesRequestBuilder(mock(Client.class)); builder.source("elastic", new BytesArray(json.getBytes(StandardCharsets.UTF_8)), XContentType.JSON); final HasPrivilegesRequest request = builder.request(); assertThat(request.indexPrivileges().length, equalTo(0)); - assertThat(request.clusterPrivileges(), arrayContaining("manage", ClusterHealthAction.NAME, ClusterStatsAction.NAME)); + assertThat(request.clusterPrivileges(), arrayContaining("manage", TransportClusterHealthAction.NAME, ClusterStatsAction.NAME)); } public void testUseOfFieldLevelSecurityThrowsException() throws Exception { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java index e899102b2d363..6fb0d69175307 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java @@ -18,10 +18,10 @@ import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.client.internal.Client; @@ -300,7 +300,7 @@ public void init() throws Exception { ) ); return null; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), anyActionListener()); doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client); builder.setIndex((String) invocationOnMock.getArguments()[0]).setId((String) invocationOnMock.getArguments()[1]); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java index 69925b5640b36..ad8a24f5454c5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java @@ -23,10 +23,10 @@ import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -185,7 +185,7 @@ public void setupClient() { ) ); return null; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), anyActionListener()); doAnswer(invocationOnMock -> { BulkRequest request = (BulkRequest) invocationOnMock.getArguments()[0]; @SuppressWarnings("unchecked") diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java index fa37a2abee77f..71b91619c66b3 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.authc.service; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; @@ -20,10 +20,10 @@ import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction; import org.elasticsearch.action.bulk.BulkAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.get.GetAction; -import org.elasticsearch.action.get.MultiGetAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.TransportMultiSearchAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.cluster.metadata.IndexAbstraction; @@ -133,13 +133,13 @@ public void testElasticFleetServerPrivileges() { ).stream().map(this::mockIndexAbstraction).forEach(index -> { assertThat(role.indices().allowedIndicesMatcher(AutoPutMappingAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(false)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(index), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(index), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(index), is(false)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false)); @@ -148,13 +148,13 @@ public void testElasticFleetServerPrivileges() { final IndexAbstraction profilingIndex = mockIndexAbstraction("profiling-" + randomAlphaOfLengthBetween(1, 20)); assertThat(role.indices().allowedIndicesMatcher(AutoPutMappingAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(profilingIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(profilingIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(profilingIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(profilingIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(profilingIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(profilingIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(profilingIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(profilingIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(profilingIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(profilingIndex), is(false)); @@ -162,13 +162,13 @@ public void testElasticFleetServerPrivileges() { List.of("synthetics-" + randomAlphaOfLengthBetween(1, 20)).stream().map(this::mockIndexAbstraction).forEach(index -> { assertThat(role.indices().allowedIndicesMatcher(AutoPutMappingAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(index), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(index), is(true)); assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false)); @@ -186,12 +186,12 @@ public void testElasticFleetServerPrivileges() { ".fleet-fileds" + randomAlphaOfLengthBetween(1, 20) ).forEach(index -> { final IndexAbstraction dotFleetIndex = mockIndexAbstraction(index); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(dotFleetIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(dotFleetIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(dotFleetIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(dotFleetIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(dotFleetIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(dotFleetIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(dotFleetIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(dotFleetIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(dotFleetIndex), is(true)); @@ -201,12 +201,12 @@ public void testElasticFleetServerPrivileges() { }); final IndexAbstraction dotFleetSecretsIndex = mockIndexAbstraction(".fleet-secrets" + randomAlphaOfLengthBetween(1, 20)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(dotFleetSecretsIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(dotFleetSecretsIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(dotFleetSecretsIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(dotFleetSecretsIndex), is(false)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(dotFleetSecretsIndex), is(false)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(dotFleetSecretsIndex), is(false)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(dotFleetSecretsIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(dotFleetSecretsIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(dotFleetSecretsIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(dotFleetSecretsIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(dotFleetSecretsIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(dotFleetSecretsIndex), is(false)); @@ -220,12 +220,12 @@ public void testElasticFleetServerPrivileges() { assertThat(role.cluster().check("cluster:admin/fleet/secrets/delete", request, authentication), is(false)); final IndexAbstraction apmSampledTracesIndex = mockIndexAbstraction("traces-apm.sampled-" + randomAlphaOfLengthBetween(1, 20)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(apmSampledTracesIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(apmSampledTracesIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(apmSampledTracesIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(apmSampledTracesIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(apmSampledTracesIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(apmSampledTracesIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(apmSampledTracesIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(apmSampledTracesIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(apmSampledTracesIndex), is(true)); @@ -338,7 +338,7 @@ public void testElasticEnterpriseSearchServerAccount() { // monitoring assertThat(role.cluster().check(MonitoringBulkAction.NAME, request, authentication), is(true)); - assertThat(role.cluster().check(ClusterHealthAction.NAME, request, authentication), is(true)); + assertThat(role.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true)); // manage_ilm assertThat(role.cluster().check(GetLifecycleAction.NAME, request, authentication), is(true)); @@ -366,12 +366,12 @@ public void testElasticEnterpriseSearchServerAccount() { final IndexAbstraction enterpriseSearchIndex = mockIndexAbstraction(index); assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(enterpriseSearchIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(enterpriseSearchIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(enterpriseSearchIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(enterpriseSearchIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(enterpriseSearchIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(enterpriseSearchIndex), is(true)); - assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(enterpriseSearchIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(enterpriseSearchIndex), is(true)); + assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(enterpriseSearchIndex), is(true)); assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(enterpriseSearchIndex), is(true)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 4ad38894f5921..8a44c56b43865 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -13,12 +13,12 @@ import org.elasticsearch.action.LatchedActionListener; import org.elasticsearch.action.MockIndicesRequest; import org.elasticsearch.action.OriginalIndices; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.indices.alias.Alias; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; @@ -48,14 +48,14 @@ import org.elasticsearch.action.bulk.BulkShardResponse; import org.elasticsearch.action.bulk.MappingUpdatePerformer; import org.elasticsearch.action.bulk.TransportShardBulkAction; -import org.elasticsearch.action.delete.DeleteAction; import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.get.GetRequest; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.MultiGetRequest; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.ClearScrollRequest; import org.elasticsearch.action.search.ClosePointInTimeRequest; import org.elasticsearch.action.search.MultiSearchRequest; @@ -79,7 +79,7 @@ import org.elasticsearch.action.termvectors.MultiTermVectorsRequest; import org.elasticsearch.action.termvectors.TermVectorsAction; import org.elasticsearch.action.termvectors.TermVectorsRequest; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateHelper; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.cluster.ClusterState; @@ -1359,7 +1359,7 @@ public void testCreateIndexWithAliasWithoutPermissions() { assertThrowsAuthorizationException( () -> authorize(authentication, CreateIndexAction.NAME, request), - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, "test user" ); verify(auditTrail).accessGranted( @@ -1372,7 +1372,7 @@ public void testCreateIndexWithAliasWithoutPermissions() { verify(auditTrail).accessDenied( eq(requestId), eq(authentication), - eq(IndicesAliasesAction.NAME), + eq(TransportIndicesAliasesAction.NAME), eq(request), authzInfoRoles(new String[] { role.getName() }) ); @@ -1543,11 +1543,13 @@ public void testDenialErrorMessagesForClusterHealthAction() { ElasticsearchSecurityException securityException = expectThrows( ElasticsearchSecurityException.class, - () -> authorize(authentication, ClusterHealthAction.NAME, request) + () -> authorize(authentication, TransportClusterHealthAction.NAME, request) ); assertThat( securityException, - throwableWithMessage(containsString("[" + ClusterHealthAction.NAME + "] is unauthorized for user [" + user.principal() + "]")) + throwableWithMessage( + containsString("[" + TransportClusterHealthAction.NAME + "] is unauthorized for user [" + user.principal() + "]") + ) ); assertThat( securityException, @@ -1981,7 +1983,10 @@ public void testGrantAllRestrictedUserCannotExecuteOperationAgainstSecurityIndic new Tuple<>(BulkAction.NAME + "[s]", new DeleteRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id")) ); requests.add( - new Tuple<>(UpdateAction.NAME, new UpdateRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id")) + new Tuple<>( + TransportUpdateAction.NAME, + new UpdateRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id") + ) ); requests.add( new Tuple<>(BulkAction.NAME + "[s]", new IndexRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7))) @@ -1998,10 +2003,15 @@ public void testGrantAllRestrictedUserCannotExecuteOperationAgainstSecurityIndic new TermVectorsRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id") ) ); - requests.add(new Tuple<>(GetAction.NAME, new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add( new Tuple<>( - IndicesAliasesAction.NAME, + TransportGetAction.TYPE.name(), + new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id") + ) + ); + requests.add( + new Tuple<>( + TransportIndicesAliasesAction.NAME, new IndicesAliasesRequest().addAliasAction(AliasActions.add().alias("security_alias").index(INTERNAL_SECURITY_MAIN_INDEX_7)) ) ); @@ -2056,22 +2066,22 @@ public void testGrantAllRestrictedUserCannotExecuteOperationAgainstSecurityIndic // we should allow waiting for the health of the index or any index if the user has this permission ClusterHealthRequest request = new ClusterHealthRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)); - authorize(authentication, ClusterHealthAction.NAME, request); + authorize(authentication, TransportClusterHealthAction.NAME, request); verify(auditTrail).accessGranted( eq(requestId), eq(authentication), - eq(ClusterHealthAction.NAME), + eq(TransportClusterHealthAction.NAME), eq(request), authzInfoRoles(new String[] { role.getName() }) ); // multiple indices request = new ClusterHealthRequest(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7, "foo", "bar"); - authorize(authentication, ClusterHealthAction.NAME, request); + authorize(authentication, TransportClusterHealthAction.NAME, request); verify(auditTrail).accessGranted( eq(requestId), eq(authentication), - eq(ClusterHealthAction.NAME), + eq(TransportClusterHealthAction.NAME), eq(request), authzInfoRoles(new String[] { role.getName() }) ); @@ -2184,13 +2194,21 @@ public void testSuperusersCanExecuteReadOperationAgainstSecurityIndex() { new TermVectorsRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id") ) ); - requests.add(new Tuple<>(GetAction.NAME, new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add( - new Tuple<>(ClusterHealthAction.NAME, new ClusterHealthRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7))) + new Tuple<>( + TransportGetAction.TYPE.name(), + new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id") + ) + ); + requests.add( + new Tuple<>( + TransportClusterHealthAction.NAME, + new ClusterHealthRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)) + ) ); requests.add( new Tuple<>( - ClusterHealthAction.NAME, + TransportClusterHealthAction.NAME, new ClusterHealthRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "foo", "bar") ) ); @@ -2255,7 +2273,7 @@ public void testSuperusersCannotExecuteWriteOperationAgainstSecurityIndex() { ); requests.add( new Tuple<>( - IndicesAliasesAction.NAME, + TransportIndicesAliasesAction.NAME, new IndicesAliasesRequest().addAliasAction(AliasActions.add().alias("security_alias").index(INTERNAL_SECURITY_MAIN_INDEX_7)) ) ); @@ -2398,7 +2416,7 @@ public void testCompositeActionsIndicesAreCheckedAtTheShardLevel() { final String action; switch (randomIntBetween(0, 4)) { case 0 -> { - action = MultiGetAction.NAME + "[shard]"; + action = TransportMultiGetAction.NAME + "[shard]"; request = mockRequest; } case 1 -> { @@ -2639,10 +2657,10 @@ public void testAuthorizationOfSingleActionMultipleIndicesBulkItems() { ); // there's only one "access granted" record for all the bulk items verify(auditTrail).explicitIndexAccessEvent(eq(requestId), eq(AuditLevel.ACCESS_GRANTED), eq(authentication), eq(switch (opType) { - case INDEX -> IndexAction.NAME + ":op_type/index"; - case CREATE -> IndexAction.NAME + ":op_type/create"; - case UPDATE -> UpdateAction.NAME; - case DELETE -> DeleteAction.NAME; + case INDEX -> TransportIndexAction.NAME + ":op_type/index"; + case CREATE -> TransportIndexAction.NAME + ":op_type/create"; + case UPDATE -> TransportUpdateAction.NAME; + case DELETE -> TransportDeleteAction.NAME; }), argThat( indicesArrays -> indicesArrays.length == allIndexNames.size() && allIndexNames.containsAll(Arrays.asList(indicesArrays)) @@ -2679,10 +2697,10 @@ public void testAuthorizationOfSingleActionMultipleIndicesBulkItems() { eq(AuditLevel.ACCESS_DENIED), eq(badAuthentication), eq(switch (opType) { - case INDEX -> IndexAction.NAME + ":op_type/index"; - case CREATE -> IndexAction.NAME + ":op_type/create"; - case UPDATE -> UpdateAction.NAME; - case DELETE -> DeleteAction.NAME; + case INDEX -> TransportIndexAction.NAME + ":op_type/index"; + case CREATE -> TransportIndexAction.NAME + ":op_type/create"; + case UPDATE -> TransportUpdateAction.NAME; + case DELETE -> TransportDeleteAction.NAME; }), argThat( indicesArrays -> indicesArrays.length == allIndexNames.size() && allIndexNames.containsAll(Arrays.asList(indicesArrays)) @@ -2707,26 +2725,26 @@ public void testAuthorizationOfMultipleActionsSingleIndexBulkItems() { final BulkItemRequest[] items = randomArray(1, 8, BulkItemRequest[]::new, () -> { switch (randomFrom(DocWriteRequest.OpType.values())) { case INDEX -> { - actionTypes.add(IndexAction.NAME + ":op_type/index"); + actionTypes.add(TransportIndexAction.NAME + ":op_type/index"); return new BulkItemRequest( idCounter.get(), new IndexRequest(indexName).id("id" + idCounter.incrementAndGet()).opType(DocWriteRequest.OpType.INDEX) ); } case CREATE -> { - actionTypes.add(IndexAction.NAME + ":op_type/create"); + actionTypes.add(TransportIndexAction.NAME + ":op_type/create"); return new BulkItemRequest( idCounter.get(), new IndexRequest(indexName).id("id" + idCounter.incrementAndGet()).opType(DocWriteRequest.OpType.CREATE) ); } case DELETE -> { - actionTypes.add(DeleteAction.NAME); + actionTypes.add(TransportDeleteAction.NAME); deleteItems.add(idCounter.get()); return new BulkItemRequest(idCounter.get(), new DeleteRequest(indexName, "id" + idCounter.incrementAndGet())); } case UPDATE -> { - actionTypes.add(UpdateAction.NAME); + actionTypes.add(TransportUpdateAction.NAME); return new BulkItemRequest(idCounter.get(), new UpdateRequest(indexName, "id" + idCounter.incrementAndGet())); } default -> throw new IllegalStateException("Unexpected value"); @@ -2803,7 +2821,7 @@ public void testAuthorizationOfMultipleActionsSingleIndexBulkItems() { ); // there's a single granted audit entry for each action type, less the delete action (which is denied) actionTypes.forEach(actionType -> { - if (actionType.equals(DeleteAction.NAME) == false) { + if (actionType.equals(TransportDeleteAction.NAME) == false) { verify(auditTrail).explicitIndexAccessEvent( eq(indexRequestId), eq(AuditLevel.ACCESS_GRANTED), @@ -2822,7 +2840,7 @@ public void testAuthorizationOfMultipleActionsSingleIndexBulkItems() { eq(indexRequestId), eq(AuditLevel.ACCESS_DENIED), eq(indexAuthentication), - eq(DeleteAction.NAME), + eq(TransportDeleteAction.NAME), eq(new String[] { indexName }), eq(BulkItemRequest.class.getSimpleName()), eq(request.remoteAddress()), @@ -2871,7 +2889,7 @@ public void testAuthorizationOfIndividualIndexAndDeleteBulkItems() { eq(requestId), eq(AuditLevel.ACCESS_GRANTED), eq(authentication), - eq(DeleteAction.NAME), + eq(TransportDeleteAction.NAME), argThat(indicesArrays -> { Arrays.sort(indicesArrays); return Arrays.equals(indicesArrays, new String[] { "alias-2", "concrete-index" }); @@ -2884,7 +2902,7 @@ public void testAuthorizationOfIndividualIndexAndDeleteBulkItems() { eq(requestId), eq(AuditLevel.ACCESS_GRANTED), eq(authentication), - eq(IndexAction.NAME + ":op_type/index"), + eq(TransportIndexAction.NAME + ":op_type/index"), argThat(indicesArrays -> { Arrays.sort(indicesArrays); return Arrays.equals(indicesArrays, new String[] { "alias-1", "concrete-index" }); @@ -2897,7 +2915,7 @@ public void testAuthorizationOfIndividualIndexAndDeleteBulkItems() { eq(requestId), eq(AuditLevel.ACCESS_DENIED), eq(authentication), - eq(DeleteAction.NAME), + eq(TransportDeleteAction.NAME), eq(new String[] { "alias-1" }), eq(BulkItemRequest.class.getSimpleName()), eq(request.remoteAddress()), @@ -2907,7 +2925,7 @@ public void testAuthorizationOfIndividualIndexAndDeleteBulkItems() { eq(requestId), eq(AuditLevel.ACCESS_DENIED), eq(authentication), - eq(IndexAction.NAME + ":op_type/index"), + eq(TransportIndexAction.NAME + ":op_type/index"), eq(new String[] { "alias-2" }), eq(BulkItemRequest.class.getSimpleName()), eq(request.remoteAddress()), @@ -2958,7 +2976,7 @@ public void testAuthorizationOfIndividualBulkItemsWithDateMath() { eq(requestId), eq(AuditLevel.ACCESS_DENIED), eq(authentication), - eq(DeleteAction.NAME), + eq(TransportDeleteAction.NAME), argThat(indices -> indices.length == 2 && indices[0].startsWith("datemath-") && indices[1].startsWith("datemath-")), eq(BulkItemRequest.class.getSimpleName()), eq(request.remoteAddress()), @@ -2969,7 +2987,7 @@ public void testAuthorizationOfIndividualBulkItemsWithDateMath() { eq(requestId), eq(AuditLevel.ACCESS_GRANTED), eq(authentication), - eq(IndexAction.NAME + ":op_type/index"), + eq(TransportIndexAction.NAME + ":op_type/index"), argThat(indices -> indices.length == 2 && indices[0].startsWith("datemath-") && indices[1].startsWith("datemath-")), eq(BulkItemRequest.class.getSimpleName()), eq(request.remoteAddress()), @@ -2997,7 +3015,7 @@ private BulkShardRequest createBulkShardRequest(String indexName, BiFunction randomCompositeRequest() { return switch (randomIntBetween(0, 7)) { - case 0 -> Tuple.tuple(MultiGetAction.NAME, new MultiGetRequest().add("index", "id")); + case 0 -> Tuple.tuple(TransportMultiGetAction.NAME, new MultiGetRequest().add("index", "id")); case 1 -> Tuple.tuple(TransportMultiSearchAction.TYPE.name(), new MultiSearchRequest().add(new SearchRequest())); case 2 -> Tuple.tuple(MultiTermVectorsAction.NAME, new MultiTermVectorsRequest().add("index", "id")); case 3 -> Tuple.tuple(BulkAction.NAME, new BulkRequest().add(new DeleteRequest("index", "id"))); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index ad4d93ea623d5..6573a0e23e506 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -8,21 +8,21 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.IndicesRequest; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesAction; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.search.MultiSearchRequest; import org.elasticsearch.action.search.SearchRequest; @@ -838,7 +838,7 @@ public void testResolveIndicesAliasesRequest() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.add().alias("alias1").indices("foo", "foofoo")); request.addAliasAction(AliasActions.add().alias("alias2").indices("foo", "foobar")); - List indices = resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)).getLocal(); + List indices = resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)).getLocal(); // the union of all indices and aliases gets returned String[] expectedIndices = new String[] { "alias1", "alias2", "foo", "foofoo", "foobar" }; assertSameValues(indices, expectedIndices); @@ -852,7 +852,7 @@ public void testResolveIndicesAliasesRequestExistingAlias() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.add().alias("alias1").indices("foo", "foofoo")); request.addAliasAction(AliasActions.add().alias("foofoobar").indices("foo", "foobar")); - List indices = resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)).getLocal(); + List indices = resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)).getLocal(); // the union of all indices and aliases gets returned, foofoobar is an existing alias but that doesn't make any difference String[] expectedIndices = new String[] { "alias1", "foofoobar", "foo", "foofoo", "foobar" }; assertSameValues(indices, expectedIndices); @@ -866,7 +866,7 @@ public void testResolveIndicesAliasesRequestMissingIndex() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.add().alias("alias1").indices("foo", "foofoo")); request.addAliasAction(AliasActions.add().alias("alias2").index("missing")); - List indices = resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)).getLocal(); + List indices = resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)).getLocal(); // the union of all indices and aliases gets returned, missing is not an existing index/alias but that doesn't make any difference String[] expectedIndices = new String[] { "alias1", "alias2", "foo", "foofoo", "missing" }; assertThat(indices, hasSize(expectedIndices.length)); @@ -881,7 +881,7 @@ public void testResolveWildcardsIndicesAliasesRequest() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.add().alias("foo-alias").index("foo*")); request.addAliasAction(AliasActions.add().alias("alias2").index("bar*")); - List indices = resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)).getLocal(); + List indices = resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)).getLocal(); // the union of all resolved indices and aliases gets returned, based on indices and aliases that user is authorized for String[] expectedIndices = new String[] { "foo-alias", "alias2", "foofoo", "bar" }; assertThat(indices, hasSize(expectedIndices.length)); @@ -899,14 +899,17 @@ public void testResolveWildcardsIndicesAliasesRequestNoMatchingIndices() { request.addAliasAction(AliasActions.add().alias("alias2").index("bar*")); request.addAliasAction(AliasActions.add().alias("alias3").index("non_matching_*")); // if a single operation contains wildcards and ends up being resolved to no indices, it makes the whole request fail - expectThrows(IndexNotFoundException.class, () -> resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME))); + expectThrows( + IndexNotFoundException.class, + () -> resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)) + ); } public void testResolveAllIndicesAliasesRequest() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.add().alias("alias1").index("_all")); request.addAliasAction(AliasActions.add().alias("alias2").index("_all")); - List indices = resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)).getLocal(); + List indices = resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)).getLocal(); // the union of all resolved indices and aliases gets returned String[] expectedIndices = new String[] { "bar", "foofoo", "alias1", "alias2" }; assertSameValues(indices, expectedIndices); @@ -924,7 +927,7 @@ public void testResolveAllIndicesAliasesRequestNoAuthorizedIndices() { // current user is not authorized for any index, _all resolves to no indices, the request fails expectThrows( IndexNotFoundException.class, - () -> resolveIndices(request, buildAuthorizedIndices(userNoIndices, IndicesAliasesAction.NAME)) + () -> resolveIndices(request, buildAuthorizedIndices(userNoIndices, TransportIndicesAliasesAction.NAME)) ); } @@ -934,7 +937,7 @@ public void testResolveWildcardsIndicesAliasesRequestNoAuthorizedIndices() { // current user is not authorized for any index, foo* resolves to no indices, the request fails expectThrows( IndexNotFoundException.class, - () -> resolveIndices(request, buildAuthorizedIndices(userNoIndices, IndicesAliasesAction.NAME)) + () -> resolveIndices(request, buildAuthorizedIndices(userNoIndices, TransportIndicesAliasesAction.NAME)) ); } @@ -942,7 +945,7 @@ public void testResolveIndicesAliasesRequestDeleteActions() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("foo").alias("foofoobar")); request.addAliasAction(AliasActions.remove().index("foofoo").alias("barbaz")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // the union of all indices and aliases gets returned String[] expectedIndices = new String[] { "foo", "foofoobar", "foofoo", "barbaz" }; @@ -958,7 +961,7 @@ public void testResolveIndicesAliasesRequestDeleteActionsMissingIndex() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("foo").alias("foofoobar")); request.addAliasAction(AliasActions.remove().index("missing_index").alias("missing_alias")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // the union of all indices and aliases gets returned, doesn't matter is some of them don't exist String[] expectedIndices = new String[] { "foo", "foofoobar", "missing_index", "missing_alias" }; @@ -974,7 +977,7 @@ public void testResolveWildcardsIndicesAliasesRequestDeleteActions() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("foo*").alias("foofoobar")); request.addAliasAction(AliasActions.remove().index("bar*").alias("barbaz")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // union of all resolved indices and aliases gets returned, based on what user is authorized for String[] expectedIndices = new String[] { "foofoobar", "foofoo", "bar", "barbaz" }; @@ -991,7 +994,7 @@ public void testResolveAliasesWildcardsIndicesAliasesRequestDeleteActions() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("*").alias("foo*")); request.addAliasAction(AliasActions.remove().index("*bar").alias("foo*")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // union of all resolved indices and aliases gets returned, based on what user is authorized for // note that the index side will end up containing matching aliases too, which is fine, as es core would do @@ -1009,7 +1012,7 @@ public void testResolveAllAliasesWildcardsIndicesAliasesRequestDeleteActions() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("*").alias("_all")); request.addAliasAction(AliasActions.remove().index("_all").aliases("_all", "explicit")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // union of all resolved indices and aliases gets returned, based on what user is authorized for // note that the index side will end up containing matching aliases too, which is fine, as es core would do @@ -1027,7 +1030,7 @@ public void testResolveAliasesWildcardsIndicesAliasesRequestRemoveAliasActionsNo IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("foo*").alias("foo*")); request.addAliasAction(AliasActions.remove().index("*bar").alias("bar*")); - resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)); + resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)); assertThat(request.getAliasActions().get(0).aliases(), arrayContainingInAnyOrder("foofoobar", "foobarfoo")); assertThat(request.getAliasActions().get(1).aliases(), arrayContaining("*", "-*")); } @@ -1036,7 +1039,7 @@ public void testResolveAliasesWildcardsIndicesAliasesRequestRemoveIndexActions() IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.removeIndex().index("foo*")); request.addAliasAction(AliasActions.removeIndex().index("*bar")); - resolveIndices(request, buildAuthorizedIndices(user, IndicesAliasesAction.NAME)); + resolveIndices(request, buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME)); assertThat(request.getAliasActions().get(0).indices(), arrayContainingInAnyOrder("foofoo")); assertThat(request.getAliasActions().get(0).aliases(), emptyArray()); assertThat(request.getAliasActions().get(1).indices(), arrayContainingInAnyOrder("bar")); @@ -1047,7 +1050,7 @@ public void testResolveWildcardsIndicesAliasesRequestAddAndDeleteActions() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasActions.remove().index("foo*").alias("foofoobar")); request.addAliasAction(AliasActions.add().index("bar*").alias("foofoobar")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); // union of all resolved indices and aliases gets returned, based on what user is authorized for String[] expectedIndices = new String[] { "foofoobar", "foofoo", "bar" }; @@ -1514,7 +1517,7 @@ public void testRemotableRequestsAllowRemoteIndices() { new Tuple(new SearchRequest("remote:foo").indicesOptions(options), TransportSearchAction.TYPE.name()), new Tuple( new FieldCapabilitiesRequest().indices("remote:foo").indicesOptions(options), - FieldCapabilitiesAction.NAME + TransportFieldCapabilitiesAction.NAME ), new Tuple( new GraphExploreRequest().indices("remote:foo").indicesOptions(options), @@ -1534,7 +1537,10 @@ public void testRemotableRequestsAllowRemoteIndices() { public void testNonRemotableRequestDoesNotAllowRemoteIndices() { IndicesOptions options = IndicesOptions.fromOptions(true, false, false, false); Tuple tuple = randomFrom( - new Tuple(new CloseIndexRequest("remote:foo").indicesOptions(options), CloseIndexAction.NAME), + new Tuple( + new CloseIndexRequest("remote:foo").indicesOptions(options), + TransportCloseIndexAction.NAME + ), new Tuple(new DeleteIndexRequest("remote:foo").indicesOptions(options), DeleteIndexAction.NAME), new Tuple(new PutMappingRequest("remote:foo").indicesOptions(options), PutMappingAction.NAME) ); @@ -1548,7 +1554,7 @@ public void testNonRemotableRequestDoesNotAllowRemoteIndices() { public void testNonRemotableRequestDoesNotAllowRemoteWildcardIndices() { IndicesOptions options = IndicesOptions.fromOptions(randomBoolean(), true, true, true); Tuple tuple = randomFrom( - new Tuple(new CloseIndexRequest("*:*").indicesOptions(options), CloseIndexAction.NAME), + new Tuple(new CloseIndexRequest("*:*").indicesOptions(options), TransportCloseIndexAction.NAME), new Tuple(new DeleteIndexRequest("*:*").indicesOptions(options), DeleteIndexAction.NAME), new Tuple(new PutMappingRequest("*:*").indicesOptions(options), PutMappingAction.NAME) ); @@ -1606,7 +1612,7 @@ public void testXPackSecurityUserHasAccessToSecurityIndex() { aliasesRequest.addAliasAction(AliasActions.add().alias("security_alias").index(SECURITY_MAIN_ALIAS)); final AuthorizedIndices authorizedIndices = buildAuthorizedIndices( InternalUsers.XPACK_SECURITY_USER, - IndicesAliasesAction.NAME + TransportIndicesAliasesAction.NAME ); List indices = resolveIndices(aliasesRequest, authorizedIndices).getLocal(); assertThat(indices, hasItem(SECURITY_MAIN_ALIAS)); @@ -1642,7 +1648,7 @@ public void testNonXPackUserAccessingSecurityIndex() { { IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest(); aliasesRequest.addAliasAction(AliasActions.add().alias("security_alias1").index("*")); - final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(allAccessUser, IndicesAliasesAction.NAME); + final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(allAccessUser, TransportIndicesAliasesAction.NAME); List indices = resolveIndices(aliasesRequest, authorizedIndices).getLocal(); assertThat(indices, not(hasItem(SECURITY_MAIN_ALIAS))); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java index 251b692f42827..3540f0bd6a753 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/RBACEngineTests.java @@ -9,13 +9,13 @@ import org.elasticsearch.ElasticsearchRoleRestrictionException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; +import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.PlainActionFuture; @@ -312,7 +312,7 @@ public void testSameUserPermissionDoesNotAllowOtherActions() { final String action = randomFrom( PutUserAction.NAME, DeleteUserAction.NAME, - ClusterHealthAction.NAME, + TransportClusterHealthAction.NAME, ClusterStateAction.NAME, ClusterStatsAction.NAME, GetLicenseAction.NAME @@ -473,7 +473,7 @@ public void testSameUserPermissionForCrossClusterAccess() { /** * This tests that action names in the request are considered "matched" by the relevant named privilege - * (in this case that {@link DeleteAction} and {@link IndexAction} are satisfied by {@link IndexPrivilege#WRITE}). + * (in this case that {@link TransportDeleteAction} and {@link TransportIndexAction} are satisfied by {@link IndexPrivilege#WRITE}). */ public void testNamedIndexPrivilegesMatchApplicableActions() throws Exception { Role role = Role.builder(RESTRICTED_INDICES, "test1") @@ -483,24 +483,24 @@ public void testNamedIndexPrivilegesMatchApplicableActions() throws Exception { RBACAuthorizationInfo authzInfo = new RBACAuthorizationInfo(role, null); final PrivilegesCheckResult result = hasPrivileges( - IndicesPrivileges.builder().indices("academy").privileges(DeleteAction.NAME, IndexAction.NAME).build(), + IndicesPrivileges.builder().indices("academy").privileges(TransportDeleteAction.NAME, TransportIndexAction.NAME).build(), authzInfo, List.of(), - new String[] { ClusterHealthAction.NAME } + new String[] { TransportClusterHealthAction.NAME } ); assertThat(result, notNullValue()); assertThat(result.allChecksSuccess(), is(true)); assertThat(result.getDetails().cluster(), aMapWithSize(1)); - assertThat(result.getDetails().cluster().get(ClusterHealthAction.NAME), equalTo(true)); + assertThat(result.getDetails().cluster().get(TransportClusterHealthAction.NAME), equalTo(true)); assertThat(result.getDetails().index().values(), Matchers.iterableWithSize(1)); final ResourcePrivileges resourcePrivileges = result.getDetails().index().values().iterator().next(); assertThat(resourcePrivileges.getResource(), equalTo("academy")); assertThat(resourcePrivileges.getPrivileges(), aMapWithSize(2)); - assertThat(resourcePrivileges.getPrivileges().get(DeleteAction.NAME), equalTo(true)); - assertThat(resourcePrivileges.getPrivileges().get(IndexAction.NAME), equalTo(true)); + assertThat(resourcePrivileges.getPrivileges().get(TransportDeleteAction.NAME), equalTo(true)); + assertThat(resourcePrivileges.getPrivileges().get(TransportIndexAction.NAME), equalTo(true)); } /** diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/IndicesAliasesRequestInterceptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/IndicesAliasesRequestInterceptorTests.java index 9c3426d48c003..15b187edd1cea 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/IndicesAliasesRequestInterceptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/IndicesAliasesRequestInterceptorTests.java @@ -8,8 +8,8 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -77,7 +77,7 @@ public void testInterceptorThrowsWhenFLSDLSEnabled() { } else { queries = null; } - final String action = IndicesAliasesAction.NAME; + final String action = TransportIndicesAliasesAction.NAME; IndicesAccessControl accessControl = new IndicesAccessControl( true, Collections.singletonMap( @@ -133,7 +133,7 @@ public void testInterceptorThrowsWhenTargetHasGreaterPermissions() throws Except .user(new User("john", "role")) .realmRef(new RealmRef("look_name", "look_type", "node")) .build(); - final String action = IndicesAliasesAction.NAME; + final String action = TransportIndicesAliasesAction.NAME; IndicesAccessControl accessControl = new IndicesAccessControl(true, Collections.emptyMap()); new SecurityContext(Settings.EMPTY, threadContext).putIndicesAccessControl(accessControl); IndicesAliasesRequestInterceptor interceptor = new IndicesAliasesRequestInterceptor(threadContext, licenseState, auditTrailService); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java index 1decbf2746ebf..c52409d6e6797 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/permission/PermissionTests.java @@ -8,7 +8,7 @@ import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; -import org.elasticsearch.action.get.GetAction; +import org.elasticsearch.action.get.TransportGetAction; import org.elasticsearch.cluster.metadata.DataStreamTestHelper; import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.common.UUIDs; @@ -46,7 +46,7 @@ public void init() { } public void testAllowedIndicesMatcherAction() throws Exception { - testAllowedIndicesMatcher(permission.indices().allowedIndicesMatcher(GetAction.NAME)); + testAllowedIndicesMatcher(permission.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name())); } public void testAllowedIndicesMatcherForMappingUpdates() throws Exception { @@ -71,8 +71,8 @@ public void testAllowedIndicesMatcherForMappingUpdates() throws Exception { } public void testAllowedIndicesMatcherActionCaching() throws Exception { - IsResourceAuthorizedPredicate matcher1 = permission.indices().allowedIndicesMatcher(GetAction.NAME); - IsResourceAuthorizedPredicate matcher2 = permission.indices().allowedIndicesMatcher(GetAction.NAME); + IsResourceAuthorizedPredicate matcher1 = permission.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()); + IsResourceAuthorizedPredicate matcher2 = permission.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()); assertThat(matcher1, is(matcher2)); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java index 7bf9508ab451a..c0df3a0947c71 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java @@ -18,9 +18,9 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateAction; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; -import org.elasticsearch.action.delete.DeleteAction; -import org.elasticsearch.action.get.GetAction; -import org.elasticsearch.action.index.IndexAction; +import org.elasticsearch.action.delete.TransportDeleteAction; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.internal.Client; @@ -543,17 +543,17 @@ private void trySuccessfullyLoadSuperuserRole(CompositeRolesStore compositeRoles assertThat(role.cluster().privileges(), containsInAnyOrder(ClusterPrivilegeResolver.ALL)); assertThat(role.indices().check(TransportSearchAction.TYPE.name()), Matchers.is(true)); - assertThat(role.indices().check(IndexAction.NAME), Matchers.is(true)); + assertThat(role.indices().check(TransportIndexAction.NAME), Matchers.is(true)); final Predicate indexActionPredicate = Automatons.predicate( role.indices().allowedActionsMatcher("index-" + randomAlphaOfLengthBetween(1, 12)) ); assertThat(indexActionPredicate.test(TransportSearchAction.TYPE.name()), is(true)); - assertThat(indexActionPredicate.test(IndexAction.NAME), is(true)); + assertThat(indexActionPredicate.test(TransportIndexAction.NAME), is(true)); final Predicate securityActionPredicate = Automatons.predicate(role.indices().allowedActionsMatcher(".security")); assertThat(securityActionPredicate.test(TransportSearchAction.TYPE.name()), is(true)); - assertThat(securityActionPredicate.test(IndexAction.NAME), is(false)); + assertThat(securityActionPredicate.test(TransportIndexAction.NAME), is(false)); } private void tryFailOnNonSuperuserRole(CompositeRolesStore compositeRolesStore, Matcher exceptionMatcher) { @@ -1037,7 +1037,7 @@ public ClusterPermission.Builder buildPermission(ClusterPermission.Builder build assertThat(role.cluster().check(PutUserAction.NAME, randomFrom(request1, request2), authentication), equalTo(true)); assertThat(role.cluster().check(PutUserAction.NAME, request3, authentication), equalTo(false)); - final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(GetAction.NAME); + final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()); assertThat(allowedRead.test(mockIndexAbstraction("abc-123")), equalTo(true)); assertThat(allowedRead.test(mockIndexAbstraction("xyz-000")), equalTo(true)); assertThat(allowedRead.test(mockIndexAbstraction("ind-1-a")), equalTo(true)); @@ -1050,7 +1050,7 @@ public ClusterPermission.Builder buildPermission(ClusterPermission.Builder build assertThat(allowedRead.test(mockIndexAbstraction("remote-idx-2-1")), equalTo(false)); assertThat(allowedRead.test(mockIndexAbstraction("remote-idx-3-1")), equalTo(false)); - final IsResourceAuthorizedPredicate allowedWrite = role.indices().allowedIndicesMatcher(IndexAction.NAME); + final IsResourceAuthorizedPredicate allowedWrite = role.indices().allowedIndicesMatcher(TransportIndexAction.NAME); assertThat(allowedWrite.test(mockIndexAbstraction("abc-123")), equalTo(true)); assertThat(allowedWrite.test(mockIndexAbstraction("xyz-000")), equalTo(false)); assertThat(allowedWrite.test(mockIndexAbstraction("ind-1-a")), equalTo(true)); @@ -1233,7 +1233,7 @@ public void testBuildRoleWithRemoteIndicesDoesNotMergeWhenNothingToMerge() { assertHasRemoteGroupsForClusters(role.remoteIndices(), Set.of("remote-1"), Set.of("*")); assertHasIndexGroupsForClusters(role.remoteIndices(), Set.of("*"), indexGroup("index-1")); assertHasIndexGroupsForClusters(role.remoteIndices(), Set.of("remote-1"), indexGroup("index-1")); - final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(GetAction.NAME); + final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()); assertThat(allowedRead.test(mockIndexAbstraction("index-1")), equalTo(true)); assertThat(allowedRead.test(mockIndexAbstraction("foo")), equalTo(false)); } @@ -1252,9 +1252,9 @@ public void testBuildRoleWithRemoteIndicesDoesNotCombineRemotesAndLocals() { ); assertHasRemoteGroupsForClusters(role.remoteIndices(), Set.of("*")); assertHasIndexGroupsForClusters(role.remoteIndices(), Set.of("*"), indexGroup("index-1")); - final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(GetAction.NAME); + final IsResourceAuthorizedPredicate allowedRead = role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()); assertThat(allowedRead.test(mockIndexAbstraction("index-1")), equalTo(true)); - final IsResourceAuthorizedPredicate allowedWrite = role.indices().allowedIndicesMatcher(IndexAction.NAME); + final IsResourceAuthorizedPredicate allowedWrite = role.indices().allowedIndicesMatcher(TransportIndexAction.NAME); assertThat(allowedWrite.test(mockIndexAbstraction("index-1")), equalTo(true)); } @@ -2592,7 +2592,12 @@ public void testCacheEntryIsReusedForIdenticalApiKeyRoles() { } public void testXPackSecurityUserCanAccessAnyIndex() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { IsResourceAuthorizedPredicate predicate = getXPackSecurityRole().indices().allowedIndicesMatcher(action); IndexAbstraction index = mockIndexAbstraction(randomAlphaOfLengthBetween(3, 12)); @@ -2607,7 +2612,12 @@ public void testXPackSecurityUserCanAccessAnyIndex() { } public void testSecurityProfileUserHasAccessForOnlyProfileIndex() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { IsResourceAuthorizedPredicate predicate = getSecurityProfileRole().indices().allowedIndicesMatcher(action); List.of( @@ -2631,7 +2641,12 @@ public void testSecurityProfileUserHasAccessForOnlyProfileIndex() { } public void testXPackUserCanAccessNonRestrictedIndices() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { IsResourceAuthorizedPredicate predicate = getXPackUserRole().indices().allowedIndicesMatcher(action); IndexAbstraction index = mockIndexAbstraction(randomAlphaOfLengthBetween(3, 12)); if (false == TestRestrictedIndices.RESTRICTED_INDICES.isRestricted(index.getName())) { @@ -2645,7 +2660,12 @@ public void testXPackUserCanAccessNonRestrictedIndices() { } public void testXPackUserCannotAccessSecurityOrAsyncSearch() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { IsResourceAuthorizedPredicate predicate = getXPackUserRole().indices().allowedIndicesMatcher(action); for (String index : TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES) { assertThat(predicate.test(mockIndexAbstraction(index)), Matchers.is(false)); @@ -2658,7 +2678,12 @@ public void testXPackUserCannotAccessSecurityOrAsyncSearch() { } public void testAsyncSearchUserCannotAccessNonRestrictedIndices() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { IsResourceAuthorizedPredicate predicate = getAsyncSearchUserRole().indices().allowedIndicesMatcher(action); IndexAbstraction index = mockIndexAbstraction(randomAlphaOfLengthBetween(3, 12)); if (false == TestRestrictedIndices.RESTRICTED_INDICES.isRestricted(index.getName())) { @@ -2672,7 +2697,12 @@ public void testAsyncSearchUserCannotAccessNonRestrictedIndices() { } public void testAsyncSearchUserCanAccessOnlyAsyncSearchRestrictedIndices() { - for (String action : Arrays.asList(GetAction.NAME, DeleteAction.NAME, TransportSearchAction.TYPE.name(), IndexAction.NAME)) { + for (String action : Arrays.asList( + TransportGetAction.TYPE.name(), + TransportDeleteAction.NAME, + TransportSearchAction.TYPE.name(), + TransportIndexAction.NAME + )) { final IsResourceAuthorizedPredicate predicate = getAsyncSearchUserRole().indices().allowedIndicesMatcher(action); for (String index : TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES) { assertThat(predicate.test(mockIndexAbstraction(index)), Matchers.is(false)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/profile/ProfileServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/profile/ProfileServiceTests.java index 496b2245ad80b..3512ac4b613d5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/profile/ProfileServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/profile/ProfileServiceTests.java @@ -13,13 +13,13 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; -import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.get.MultiGetAction; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetResponse; +import org.elasticsearch.action.get.TransportGetAction; +import org.elasticsearch.action.get.TransportMultiGetAction; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.MultiSearchRequest; import org.elasticsearch.action.search.MultiSearchRequestBuilder; @@ -30,7 +30,7 @@ import org.elasticsearch.action.search.TransportMultiSearchAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.action.update.UpdateAction; +import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.action.update.UpdateResponse; @@ -355,7 +355,7 @@ public void testGetProfileSubjectsWithMissingUids() throws Exception { final ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(new MultiGetResponse(responses.toArray(MultiGetItemResponse[]::new))); return null; - }).when(client).execute(eq(MultiGetAction.INSTANCE), any(MultiGetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportMultiGetAction.TYPE), any(MultiGetRequest.class), anyActionListener()); final PlainActionFuture>> future = new PlainActionFuture<>(); profileService.getProfileSubjects(allProfileUids, future); @@ -389,7 +389,7 @@ public void testGetProfileSubjectWithFailures() throws Exception { final ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(mGetException); return null; - }).when(client).execute(eq(MultiGetAction.INSTANCE), any(MultiGetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportMultiGetAction.TYPE), any(MultiGetRequest.class), anyActionListener()); final PlainActionFuture>> future = new PlainActionFuture<>(); profileService.getProfileSubjects(randomList(1, 5, () -> randomAlphaOfLength(20)), future); ExecutionException e = expectThrows(ExecutionException.class, () -> future.get()); @@ -422,7 +422,7 @@ public void testGetProfileSubjectWithFailures() throws Exception { final ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onResponse(new MultiGetResponse(responses.toArray(MultiGetItemResponse[]::new))); return null; - }).when(client).execute(eq(MultiGetAction.INSTANCE), any(MultiGetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportMultiGetAction.TYPE), any(MultiGetRequest.class), anyActionListener()); final PlainActionFuture>> future2 = new PlainActionFuture<>(); profileService.getProfileSubjects(allProfileUids, future2); @@ -622,7 +622,7 @@ public void testSecurityProfileOrigin() { final ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(expectedException); return null; - }).when(client).execute(eq(UpdateAction.INSTANCE), any(UpdateRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportUpdateAction.TYPE), any(UpdateRequest.class), anyActionListener()); final PlainActionFuture future2 = new PlainActionFuture<>(); profileService.doUpdate(mock(UpdateRequest.class), future2); final RuntimeException e2 = expectThrows(RuntimeException.class, future2::actionGet); @@ -956,7 +956,7 @@ public void testActivateWhenShouldSkipUpdateForActivateReturnsFalseFirst() throw final var listener = (ActionListener) invocation.getArguments()[2]; client.get(getRequest, listener); return null; - }).when(client).execute(eq(GetAction.INSTANCE), any(GetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportGetAction.TYPE), any(GetRequest.class), anyActionListener()); // First check returns false, second check return true or false randomly final boolean secondCheckResult = randomBoolean(); @@ -999,7 +999,7 @@ public void testActivateWhenGetRequestErrors() throws IOException { final var listener = (ActionListener) invocation.getArguments()[2]; client.get(getRequest, listener); return null; - }).when(client).execute(eq(GetAction.INSTANCE), any(GetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportGetAction.TYPE), any(GetRequest.class), anyActionListener()); // First check returns false doAnswer(invocation -> false).when(service).shouldSkipUpdateForActivate(any(), any()); @@ -1079,7 +1079,7 @@ private void mockMultiGetRequest(List sampleDocumentPar final ActionListener listener = (ActionListener) invocation.getArguments()[2]; client.multiGet(multiGetRequest, listener); return null; - }).when(client).execute(eq(MultiGetAction.INSTANCE), any(MultiGetRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportMultiGetAction.TYPE), any(MultiGetRequest.class), anyActionListener()); final Map results = sampleDocumentParameters.stream() .collect( diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java index 995163572f888..97cd99e58e92f 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java @@ -16,10 +16,10 @@ import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -228,7 +228,7 @@ public static void mockIndexRequest(Client client, String indexAliasName, Consum final ShardId shardId = new ShardId(request.index(), ESTestCase.randomAlphaOfLength(12), 0); listener.onResponse(new IndexResponse(shardId, request.id(), 1, 1, 1, true)); return null; - }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), anyActionListener()); + }).when(client).execute(eq(TransportIndexAction.TYPE), any(IndexRequest.class), anyActionListener()); } @SuppressWarnings("unchecked") diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java index c22892df2ce52..1ecd85cadab46 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.MockIndicesRequest; -import org.elasticsearch.action.admin.indices.close.CloseIndexAction; +import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.admin.indices.delete.DeleteIndexAction; import org.elasticsearch.action.admin.indices.open.OpenIndexAction; import org.elasticsearch.action.search.TransportSearchAction; @@ -188,7 +188,7 @@ public void testCrossClusterAccessInboundMissingHeadersFail() { } public void testInboundDestructiveOperations() { - String action = randomFrom(CloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); + String action = randomFrom(TransportCloseIndexAction.NAME, OpenIndexAction.NAME, DeleteIndexAction.NAME); TransportRequest request = new MockIndicesRequest( IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), randomFrom("*", "_all", "test*") diff --git a/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStoreTests.java b/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStoreTests.java index 6b2e23594ec3f..082b097df684b 100644 --- a/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStoreTests.java +++ b/x-pack/plugin/slm/src/test/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStoreTests.java @@ -10,9 +10,9 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; @@ -38,6 +38,7 @@ import static org.elasticsearch.xpack.slm.history.SnapshotHistoryStore.SLM_HISTORY_DATA_STREAM; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.sameInstance; import static org.hamcrest.core.IsEqual.equalTo; public class SnapshotHistoryStoreTests extends ESTestCase { @@ -102,7 +103,7 @@ public void testPut() throws Exception { AtomicInteger calledTimes = new AtomicInteger(0); client.setVerifier((action, request, listener) -> { calledTimes.incrementAndGet(); - assertThat(action, instanceOf(IndexAction.class)); + assertThat(action, sameInstance(TransportIndexAction.TYPE)); assertThat(request, instanceOf(IndexRequest.class)); IndexRequest indexRequest = (IndexRequest) request; assertEquals(SLM_HISTORY_DATA_STREAM, indexRequest.index()); @@ -140,7 +141,7 @@ public void testPut() throws Exception { return new CreateIndexResponse(true, true, ((CreateIndexRequest) request).index()); } calledTimes.incrementAndGet(); - assertThat(action, instanceOf(IndexAction.class)); + assertThat(action, sameInstance(TransportIndexAction.TYPE)); assertThat(request, instanceOf(IndexRequest.class)); IndexRequest indexRequest = (IndexRequest) request; assertEquals(SLM_HISTORY_DATA_STREAM, indexRequest.index()); diff --git a/x-pack/plugin/sql/qa/server/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/SqlSecurityTestCase.java b/x-pack/plugin/sql/qa/server/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/SqlSecurityTestCase.java index 0ab942fcff39f..e30934050bfb9 100644 --- a/x-pack/plugin/sql/qa/server/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/SqlSecurityTestCase.java +++ b/x-pack/plugin/sql/qa/server/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/SqlSecurityTestCase.java @@ -11,8 +11,8 @@ import org.elasticsearch.SpecialPermission; import org.elasticsearch.action.admin.indices.get.GetIndexAction; import org.elasticsearch.action.admin.indices.get.GetIndexRequest; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.client.Request; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; @@ -281,7 +281,7 @@ public void testQueryWrongAccess() throws Exception { // This user has permission to run sql queries so they are given preliminary authorization .expect(true, SQL_ACTION_NAME, "wrong_access", empty()) // the following get index is granted too but against the no indices placeholder, as ignore_unavailable=true - .expect(true, FieldCapabilitiesAction.NAME, "wrong_access", hasItems("*", "-*")) + .expect(true, TransportFieldCapabilitiesAction.NAME, "wrong_access", hasItems("*", "-*")) .assertLogs(); } @@ -442,7 +442,7 @@ public void testDescribeWithWrongAccess() throws Exception { // This user has permission to run sql queries so they are given preliminary authorization .expect(true, SQL_ACTION_NAME, "wrong_access", empty()) // the following get index is granted too but against the no indices placeholder, as ignore_unavailable=true - .expect(true, FieldCapabilitiesAction.NAME, "wrong_access", hasItems("*", "-*")) + .expect(true, TransportFieldCapabilitiesAction.NAME, "wrong_access", hasItems("*", "-*")) .assertLogs(); } @@ -518,7 +518,7 @@ public AuditLogAsserter expectSqlCompositeActionGetIndex(String user, String... public AuditLogAsserter expectSqlCompositeActionFieldCaps(String user, String... indices) { expect(true, SQL_ACTION_NAME, user, empty()); - expect(true, FieldCapabilitiesAction.NAME, user, hasItems(indices)); + expect(true, TransportFieldCapabilitiesAction.NAME, user, hasItems(indices)); return this; } @@ -531,7 +531,7 @@ public AuditLogAsserter expect( String request = switch (action) { case SQL_ACTION_NAME -> "SqlQueryRequest"; case GetIndexAction.NAME -> GetIndexRequest.class.getSimpleName(); - case FieldCapabilitiesAction.NAME -> FieldCapabilitiesRequest.class.getSimpleName(); + case TransportFieldCapabilitiesAction.NAME -> FieldCapabilitiesRequest.class.getSimpleName(); default -> throw new IllegalArgumentException("Unknown action [" + action + "]"); }; final String eventAction = granted ? "access_granted" : "access_denied"; @@ -631,7 +631,7 @@ public void assertLogs() throws Exception { assertThat(log.containsKey("action"), is(true)); if (false == (SQL_ACTION_NAME.equals(log.get("action")) || GetIndexAction.NAME.equals(log.get("action")) - || FieldCapabilitiesAction.NAME.equals(log.get("action")))) { + || TransportFieldCapabilitiesAction.NAME.equals(log.get("action")))) { // TODO we may want to extend this and the assertions to SearchAction.NAME as well continue; } diff --git a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java index f6aa45fd9c312..f667ae4b80d03 100644 --- a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java +++ b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java @@ -14,7 +14,7 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.action.support.ActionFilterChain; import org.elasticsearch.common.settings.Settings; @@ -213,7 +213,7 @@ public void app ActionFilterChain chain ) { - if (action.equals(FieldCapabilitiesAction.NAME)) { + if (action.equals(TransportFieldCapabilitiesAction.NAME)) { final Consumer actionWrapper = resp -> { try { fieldCaps.incrementAndGet(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java index 5d9a3971ad082..e87cf1ca7fc8d 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/IndexBasedTransformConfigManager.java @@ -20,8 +20,8 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.bulk.BulkItemResponse; -import org.elasticsearch.action.index.IndexAction; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.TransportIndexAction; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.TransportSearchAction; @@ -135,13 +135,9 @@ public void putTransformCheckpoint(TransformCheckpoint checkpoint, ActionListene .id(TransformCheckpoint.documentId(checkpoint.getTransformId(), checkpoint.getCheckpoint())) .source(source); - executeAsyncWithOrigin( - client, - TRANSFORM_ORIGIN, - IndexAction.INSTANCE, - indexRequest, - ActionListener.wrap(r -> { listener.onResponse(true); }, listener::onFailure) - ); + executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, TransportIndexAction.TYPE, indexRequest, ActionListener.wrap(r -> { + listener.onResponse(true); + }, listener::onFailure)); } catch (IOException e) { // not expected to happen but for the sake of completeness listener.onFailure(e); @@ -335,32 +331,28 @@ private void putTransformConfiguration( if (seqNoPrimaryTermAndIndex != null) { indexRequest.setIfSeqNo(seqNoPrimaryTermAndIndex.getSeqNo()).setIfPrimaryTerm(seqNoPrimaryTermAndIndex.getPrimaryTerm()); } - executeAsyncWithOrigin( - client, - TRANSFORM_ORIGIN, - IndexAction.INSTANCE, - indexRequest, - ActionListener.wrap(r -> { listener.onResponse(true); }, e -> { - if (e instanceof VersionConflictEngineException) { - if (DocWriteRequest.OpType.CREATE.equals(opType)) { // we want to create the transform but it already exists - listener.onFailure( - new ResourceAlreadyExistsException( - TransformMessages.getMessage(TransformMessages.REST_PUT_TRANSFORM_EXISTS, transformConfig.getId()) - ) - ); - } else { // we want to update the transform but it got updated in the meantime, report version conflict - listener.onFailure( - new ElasticsearchStatusException( - TransformMessages.getMessage(TransformMessages.REST_UPDATE_TRANSFORM_CONFLICT, transformConfig.getId()), - RestStatus.CONFLICT - ) - ); - } - } else { - listener.onFailure(new RuntimeException(TransformMessages.REST_PUT_FAILED_PERSIST_TRANSFORM_CONFIGURATION, e)); + executeAsyncWithOrigin(client, TRANSFORM_ORIGIN, TransportIndexAction.TYPE, indexRequest, ActionListener.wrap(r -> { + listener.onResponse(true); + }, e -> { + if (e instanceof VersionConflictEngineException) { + if (DocWriteRequest.OpType.CREATE.equals(opType)) { // we want to create the transform but it already exists + listener.onFailure( + new ResourceAlreadyExistsException( + TransformMessages.getMessage(TransformMessages.REST_PUT_TRANSFORM_EXISTS, transformConfig.getId()) + ) + ); + } else { // we want to update the transform but it got updated in the meantime, report version conflict + listener.onFailure( + new ElasticsearchStatusException( + TransformMessages.getMessage(TransformMessages.REST_UPDATE_TRANSFORM_CONFLICT, transformConfig.getId()), + RestStatus.CONFLICT + ) + ); } - }) - ); + } else { + listener.onFailure(new RuntimeException(TransformMessages.REST_PUT_FAILED_PERSIST_TRANSFORM_CONFIGURATION, e)); + } + })); } catch (IOException e) { // not expected to happen but for the sake of completeness listener.onFailure( @@ -717,7 +709,7 @@ public void putOrUpdateTransformStoredDoc( executeAsyncWithOrigin( client, TRANSFORM_ORIGIN, - IndexAction.INSTANCE, + TransportIndexAction.TYPE, indexRequest, ActionListener.wrap( r -> listener.onResponse(SeqNoPrimaryTermAndIndex.fromIndexResponse(r)), diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java index 86d03ca37fc57..a08612fa4be72 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformIndex.java @@ -12,8 +12,8 @@ import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.Alias; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.get.GetIndexAction; @@ -233,7 +233,7 @@ static void setUpDestinationAliases(Client client, TransformConfig config, Actio config.getHeaders(), TRANSFORM_ORIGIN, client, - IndicesAliasesAction.INSTANCE, + TransportIndicesAliasesAction.TYPE, request, ActionListener.wrap(aliasesResponse -> { listener.onResponse(true); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java index 3b6ea7758947a..a07f5c987c30c 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java @@ -10,8 +10,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; +import org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.Client; import org.elasticsearch.core.Tuple; @@ -196,7 +196,7 @@ public static void getDestinationFieldMappings( ClientHelper.executeAsyncWithOrigin( client, ClientHelper.TRANSFORM_ORIGIN, - FieldCapabilitiesAction.INSTANCE, + TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, ActionListener.wrap(r -> listener.onResponse(extractFieldMappings(r)), listener::onFailure) ); @@ -281,7 +281,7 @@ static void getSourceFieldMappings( headers, ClientHelper.TRANSFORM_ORIGIN, client, - FieldCapabilitiesAction.INSTANCE, + TransportFieldCapabilitiesAction.TYPE, fieldCapabilitiesRequest, ActionListener.wrap(response -> listener.onResponse(extractFieldMappings(response)), listener::onFailure) ); diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java index 5afb6db1856fe..9db4ba1fc73b6 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/TransformIndexTests.java @@ -8,8 +8,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.LatchedActionListener; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; +import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; import org.elasticsearch.action.admin.indices.create.CreateIndexAction; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.get.GetIndexAction; @@ -203,7 +203,7 @@ public void testSetUpDestinationAliases() { TransformIndex.setUpDestinationAliases(client, config, ActionTestUtils.assertNoFailureListener(Assert::assertTrue)); ArgumentCaptor indicesAliasesRequestCaptor = ArgumentCaptor.forClass(IndicesAliasesRequest.class); - verify(client).execute(eq(IndicesAliasesAction.INSTANCE), indicesAliasesRequestCaptor.capture(), any()); + verify(client).execute(eq(TransportIndicesAliasesAction.TYPE), indicesAliasesRequestCaptor.capture(), any()); verify(client, atLeastOnce()).threadPool(); verifyNoMoreInteractions(client);