|
|
@@ -132,6 +132,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(ReservedRolesStore.isReserved("watcher_user"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("watcher_admin"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("kibana_dashboard_only_user"), is(true));
|
|
|
+ assertThat(ReservedRolesStore.isReserved("beats_admin"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved(XPackUser.ROLE_NAME), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved(LogstashSystemUser.ROLE_NAME), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved(BeatsSystemUser.ROLE_NAME), is(true));
|
|
|
@@ -220,6 +221,20 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
|
|
|
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(true));
|
|
|
});
|
|
|
+
|
|
|
+ // Beats management index
|
|
|
+ final String index = ".management-beats";
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(false));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
|
|
|
+ assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(false));
|
|
|
}
|
|
|
|
|
|
public void testKibanaUserRole() {
|
|
|
@@ -478,6 +493,39 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
is(false));
|
|
|
}
|
|
|
|
|
|
+ public void testBeatsAdminRole() {
|
|
|
+ final RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor("beats_admin");
|
|
|
+ assertNotNull(roleDescriptor);
|
|
|
+ assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
+
|
|
|
+ final Role beatsAdminRole = Role.builder(roleDescriptor, null).build();
|
|
|
+ assertThat(beatsAdminRole.cluster().check(ClusterHealthAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(ClusterStateAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(ClusterStatsAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(PutIndexTemplateAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(ClusterRerouteAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(ClusterUpdateSettingsAction.NAME), is(false));
|
|
|
+ assertThat(beatsAdminRole.cluster().check(MonitoringBulkAction.NAME), is(false));
|
|
|
+
|
|
|
+ assertThat(beatsAdminRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
|
|
|
+
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
|
|
|
+ is(false));
|
|
|
+
|
|
|
+ final String index = ".management-beats";
|
|
|
+ logger.info("index name [{}]", index);
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
|
|
|
+ assertThat(beatsAdminRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
|
|
|
+ }
|
|
|
+
|
|
|
public void testBeatsSystemRole() {
|
|
|
RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor(BeatsSystemUser.ROLE_NAME);
|
|
|
assertNotNull(roleDescriptor);
|