|
|
@@ -52,6 +52,7 @@ import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.util.set.Sets;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
import org.elasticsearch.transport.TransportRequest;
|
|
|
+import org.elasticsearch.xpack.core.XPackPlugin;
|
|
|
import org.elasticsearch.xpack.core.action.XPackInfoAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.action.DeleteLifecycleAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.action.GetLifecycleAction;
|
|
|
@@ -186,6 +187,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.SortedMap;
|
|
|
|
|
|
+import static org.elasticsearch.xpack.core.security.test.TestRestrictedIndices.RESTRICTED_INDICES_AUTOMATON;
|
|
|
import static org.hamcrest.Matchers.hasEntry;
|
|
|
import static org.hamcrest.Matchers.is;
|
|
|
import static org.hamcrest.Matchers.not;
|
|
|
@@ -241,7 +243,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role snapshotUserRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role snapshotUserRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(snapshotUserRole.cluster().check(GetRepositoriesAction.NAME, request, authentication), is(true));
|
|
|
assertThat(snapshotUserRole.cluster().check(CreateSnapshotAction.NAME, request, authentication), is(true));
|
|
|
assertThat(snapshotUserRole.cluster().check(SnapshotsStatusAction.NAME, request, authentication), is(true));
|
|
|
@@ -284,10 +286,10 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
mockIndexAbstraction(index)), is(true));
|
|
|
}
|
|
|
assertThat(snapshotUserRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(
|
|
|
- mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
|
|
|
assertNoAccessAllowed(snapshotUserRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(snapshotUserRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(snapshotUserRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testIngestAdminRole() {
|
|
|
@@ -298,7 +300,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role ingestAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role ingestAdminRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(ingestAdminRole.cluster().check(PutIndexTemplateAction.NAME, request, authentication), is(true));
|
|
|
assertThat(ingestAdminRole.cluster().check(GetIndexTemplatesAction.NAME, request, authentication), is(true));
|
|
|
assertThat(ingestAdminRole.cluster().check(DeleteIndexTemplateAction.NAME, request, authentication), is(true));
|
|
|
@@ -317,7 +319,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(ingestAdminRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(ingestAdminRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(ingestAdminRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testKibanaSystemRole() {
|
|
|
@@ -328,7 +330,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role kibanaRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role kibanaRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(kibanaRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -595,7 +597,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(kibanaRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(kibanaRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(kibanaRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testKibanaAdminRole() {
|
|
|
@@ -607,7 +609,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
assertThat(roleDescriptor.getMetadata(), not(hasEntry("_deprecated", true)));
|
|
|
|
|
|
- Role kibanaAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role kibanaAdminRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(kibanaAdminRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -654,7 +656,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_deprecated", true));
|
|
|
|
|
|
- Role kibanaUserRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role kibanaUserRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(kibanaUserRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -683,7 +685,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
"*"), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(kibanaUserRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(kibanaUserRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(kibanaUserRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testMonitoringUserRole() {
|
|
|
@@ -694,7 +696,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role monitoringUserRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role monitoringUserRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(monitoringUserRole.cluster().check(MainAction.NAME, request, authentication), is(true));
|
|
|
assertThat(monitoringUserRole.cluster().check(XPackInfoAction.NAME, request, authentication), is(true));
|
|
|
assertThat(monitoringUserRole.cluster().check(RemoteInfoAction.NAME, request, authentication), is(true));
|
|
|
@@ -737,7 +739,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(monitoringUserRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(true));
|
|
|
|
|
|
assertNoAccessAllowed(monitoringUserRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(monitoringUserRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(monitoringUserRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
|
|
|
final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
assertThat(monitoringUserRole.application().grants(
|
|
|
@@ -760,7 +762,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role remoteMonitoringAgentRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role remoteMonitoringAgentRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(remoteMonitoringAgentRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -847,7 +849,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
.test(mockIndexAbstraction(metricbeatIndex)), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(remoteMonitoringAgentRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(remoteMonitoringAgentRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(remoteMonitoringAgentRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testRemoteMonitoringCollectorRole() {
|
|
|
@@ -858,7 +860,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role remoteMonitoringCollectorRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role remoteMonitoringCollectorRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(remoteMonitoringCollectorRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -923,45 +925,45 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetSettingsAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetSettingsAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesShardStoresAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesShardStoresAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(RecoveryAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(RecoveryAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesStatsAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesStatsAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesSegmentsAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(true));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndicesSegmentsAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(true));
|
|
|
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(SearchAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(SearchAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(GetAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(DeleteAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(DeleteAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndexAction.NAME)
|
|
|
.test(mockIndexAbstraction(randomFrom(RestrictedIndicesNames.RESTRICTED_NAMES))), is(false));
|
|
|
assertThat(remoteMonitoringCollectorRole.indices().allowedIndicesMatcher(IndexAction.NAME)
|
|
|
- .test(mockIndexAbstraction(RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
+ .test(mockIndexAbstraction(XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2))), is(false));
|
|
|
|
|
|
assertMonitoringOnRestrictedIndices(remoteMonitoringCollectorRole);
|
|
|
|
|
|
assertNoAccessAllowed(remoteMonitoringCollectorRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(remoteMonitoringCollectorRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(remoteMonitoringCollectorRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
private void assertMonitoringOnRestrictedIndices(Role role) {
|
|
|
@@ -980,7 +982,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
final List<String> indexMonitoringActionNamesList = Arrays.asList(IndicesStatsAction.NAME, IndicesSegmentsAction.NAME,
|
|
|
GetSettingsAction.NAME, IndicesShardStoresAction.NAME, RecoveryAction.NAME);
|
|
|
for (final String indexMonitoringActionName : indexMonitoringActionNamesList) {
|
|
|
- String asyncSearchIndex = RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2);
|
|
|
+ String asyncSearchIndex = XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2);
|
|
|
final Map<String, IndexAccessControl> authzMap = role.indices().authorize(indexMonitoringActionName,
|
|
|
Sets.newHashSet(internalSecurityIndex, RestrictedIndicesNames.SECURITY_MAIN_ALIAS, asyncSearchIndex),
|
|
|
metadata.getIndicesLookup(), fieldPermissionsCache);
|
|
|
@@ -999,7 +1001,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_deprecated", true));
|
|
|
|
|
|
- Role reportingUserRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role reportingUserRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(reportingUserRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1034,7 +1036,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(reportingUserRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(reportingUserRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(reportingUserRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(reportingUserRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testSuperuserRole() {
|
|
|
@@ -1045,7 +1047,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role superuserRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role superuserRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(superuserRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1117,7 +1119,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role logstashSystemRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role logstashSystemRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(logstashSystemRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1136,7 +1138,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
.test(mockIndexAbstraction(randomAlphaOfLengthBetween(8, 24))), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(logstashSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(logstashSystemRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(logstashSystemRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testBeatsAdminRole() {
|
|
|
@@ -1148,7 +1150,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
|
|
|
- final Role beatsAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ final Role beatsAdminRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(beatsAdminRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1177,7 +1179,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(beatsAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true));
|
|
|
|
|
|
assertNoAccessAllowed(beatsAdminRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(beatsAdminRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(beatsAdminRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testBeatsSystemRole() {
|
|
|
@@ -1188,7 +1190,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role beatsSystemRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role beatsSystemRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(beatsSystemRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1213,7 +1215,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(true));
|
|
|
|
|
|
assertNoAccessAllowed(beatsSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(beatsSystemRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(beatsSystemRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testAPMSystemRole() {
|
|
|
@@ -1224,7 +1226,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role APMSystemRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role APMSystemRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(APMSystemRole.cluster().check(ClusterHealthAction.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));
|
|
|
@@ -1256,7 +1258,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
"indices:data/write/index:op_type/" + randomAlphaOfLengthBetween(3,5)).test(mockIndexAbstraction(index)), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(APMSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(APMSystemRole, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(APMSystemRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testAPMUserRole() {
|
|
|
@@ -1267,7 +1269,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
|
|
|
assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false));
|
|
|
@@ -1313,7 +1315,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertRoleHasManageMl(role);
|
|
|
assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
|
|
|
@@ -1328,7 +1330,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.INDEX_NAME);
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
|
|
|
final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
assertThat(role.application().grants(
|
|
|
@@ -1419,7 +1421,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(role.cluster().check(CloseJobAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.cluster().check(DeleteCalendarAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.cluster().check(DeleteCalendarEventAction.NAME, request, authentication), is(false));
|
|
|
@@ -1482,7 +1484,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.INDEX_NAME);
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
|
|
|
|
|
|
final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
@@ -1516,7 +1518,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), not(hasEntry("_deprecated", true)));
|
|
|
}
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
@@ -1535,7 +1537,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME); // internal use only
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
|
|
|
final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
assertThat(role.application().grants(
|
|
|
@@ -1574,7 +1576,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(roleDescriptor.getMetadata(), not(hasEntry("_deprecated", true)));
|
|
|
}
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
@@ -1593,7 +1595,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME);
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
|
|
|
final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
assertThat(role.application().grants(
|
|
|
@@ -1622,7 +1624,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(role.cluster().check(PutWatchAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(GetWatchAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(DeleteWatchAction.NAME, request, authentication), is(true));
|
|
|
@@ -1642,7 +1644,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testWatcherUserRole() {
|
|
|
@@ -1653,7 +1655,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(role.cluster().check(PutWatchAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.cluster().check(GetWatchAction.NAME, request, authentication), is(true));
|
|
|
assertThat(role.cluster().check(DeleteWatchAction.NAME, request, authentication), is(false));
|
|
|
@@ -1675,7 +1677,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
public void testPredefinedViewerRole() {
|
|
|
@@ -1686,7 +1688,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
// No cluster privileges
|
|
|
assertThat(role.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false));
|
|
|
assertThat(role.cluster().check(ClusterStateAction.NAME, request, authentication), is(false));
|
|
|
@@ -1735,7 +1737,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role role = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
|
|
|
// No cluster privileges
|
|
|
assertThat(role.cluster().check(ClusterHealthAction.NAME, request, authentication), is(false));
|
|
|
@@ -1817,7 +1819,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(mockIndexAbstraction(index)), is(false));
|
|
|
|
|
|
assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.ASYNC_SEARCH_PREFIX + randomAlphaOfLengthBetween(0, 2));
|
|
|
+ assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
|
|
|
}
|
|
|
|
|
|
private void assertNoAccessAllowed(Role role, Collection<String> indices) {
|
|
|
@@ -1846,7 +1848,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertNotNull(roleDescriptor);
|
|
|
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
|
|
|
- Role logstashAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ Role logstashAdminRole = Role.builder(roleDescriptor, null, RESTRICTED_INDICES_AUTOMATON).build();
|
|
|
assertThat(logstashAdminRole.cluster().check(ClusterHealthAction.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));
|