@@ -144,6 +144,7 @@ public void testIsReserved() {
144144 assertThat (ReservedRolesStore .isReserved ("watcher_user" ), is (true ));
145145 assertThat (ReservedRolesStore .isReserved ("watcher_admin" ), is (true ));
146146 assertThat (ReservedRolesStore .isReserved ("kibana_dashboard_only_user" ), is (true ));
147+ assertThat (ReservedRolesStore .isReserved ("beats_admin" ), is (true ));
147148 assertThat (ReservedRolesStore .isReserved (XPackUser .ROLE_NAME ), is (true ));
148149 assertThat (ReservedRolesStore .isReserved (LogstashSystemUser .ROLE_NAME ), is (true ));
149150 assertThat (ReservedRolesStore .isReserved (BeatsSystemUser .ROLE_NAME ), is (true ));
@@ -259,6 +260,20 @@ public void testKibanaSystemRole() {
259260 assertThat (kibanaRole .indices ().allowedIndicesMatcher (GetAction .NAME ).test (index ), is (true ));
260261 assertThat (kibanaRole .indices ().allowedIndicesMatcher (READ_CROSS_CLUSTER_NAME ).test (index ), is (true ));
261262 });
263+
264+ // Beats management index
265+ final String index = ".management-beats" ;
266+ assertThat (kibanaRole .indices ().allowedIndicesMatcher ("indices:foo" ).test (index ), is (false ));
267+ assertThat (kibanaRole .indices ().allowedIndicesMatcher ("indices:bar" ).test (index ), is (false ));
268+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (index ), is (false ));
269+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (CreateIndexAction .NAME ).test (index ), is (true ));
270+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (IndexAction .NAME ).test (index ), is (true ));
271+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteAction .NAME ).test (index ), is (true ));
272+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (UpdateSettingsAction .NAME ).test (index ), is (false ));
273+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (SearchAction .NAME ).test (index ), is (true ));
274+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (MultiSearchAction .NAME ).test (index ), is (true ));
275+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (GetAction .NAME ).test (index ), is (true ));
276+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (READ_CROSS_CLUSTER_NAME ).test (index ), is (false ));
262277 }
263278
264279 public void testKibanaUserRole () {
@@ -555,6 +570,41 @@ public void testLogstashSystemRole() {
555570 is (false ));
556571 }
557572
573+ public void testBeatsAdminRole () {
574+ final TransportRequest request = mock (TransportRequest .class );
575+
576+ final RoleDescriptor roleDescriptor = new ReservedRolesStore ().roleDescriptor ("beats_admin" );
577+ assertNotNull (roleDescriptor );
578+ assertThat (roleDescriptor .getMetadata (), hasEntry ("_reserved" , true ));
579+
580+ final Role beatsAdminRole = Role .builder (roleDescriptor , null ).build ();
581+ assertThat (beatsAdminRole .cluster ().check (ClusterHealthAction .NAME , request ), is (false ));
582+ assertThat (beatsAdminRole .cluster ().check (ClusterStateAction .NAME , request ), is (false ));
583+ assertThat (beatsAdminRole .cluster ().check (ClusterStatsAction .NAME , request ), is (false ));
584+ assertThat (beatsAdminRole .cluster ().check (PutIndexTemplateAction .NAME , request ), is (false ));
585+ assertThat (beatsAdminRole .cluster ().check (ClusterRerouteAction .NAME , request ), is (false ));
586+ assertThat (beatsAdminRole .cluster ().check (ClusterUpdateSettingsAction .NAME , request ), is (false ));
587+ assertThat (beatsAdminRole .cluster ().check (MonitoringBulkAction .NAME , request ), is (false ));
588+
589+ assertThat (beatsAdminRole .runAs ().check (randomAlphaOfLengthBetween (1 , 30 )), is (false ));
590+
591+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher ("indices:foo" ).test (randomAlphaOfLengthBetween (8 , 24 )),
592+ is (false ));
593+
594+ final String index = ".management-beats" ;
595+ logger .info ("index name [{}]" , index );
596+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher ("indices:foo" ).test (index ), is (true ));
597+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher ("indices:bar" ).test (index ), is (true ));
598+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (index ), is (true ));
599+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (CreateIndexAction .NAME ).test (index ), is (true ));
600+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (IndexAction .NAME ).test (index ), is (true ));
601+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (DeleteAction .NAME ).test (index ), is (true ));
602+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (UpdateSettingsAction .NAME ).test (index ), is (true ));
603+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (SearchAction .NAME ).test (index ), is (true ));
604+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (MultiSearchAction .NAME ).test (index ), is (true ));
605+ assertThat (beatsAdminRole .indices ().allowedIndicesMatcher (GetAction .NAME ).test (index ), is (true ));
606+ }
607+
558608 public void testBeatsSystemRole () {
559609 final TransportRequest request = mock (TransportRequest .class );
560610
0 commit comments