@@ -551,7 +551,6 @@ public void testKibanaSystemRole() {
551
551
Arrays .asList (".logs-endpoint.diagnostic.collection-" + randomAlphaOfLength (randomIntBetween (0 , 13 ))).forEach ((index ) -> {
552
552
assertThat (kibanaRole .indices ().allowedIndicesMatcher ("indices:foo" ).test (mockIndexAbstraction (index )), is (false ));
553
553
assertThat (kibanaRole .indices ().allowedIndicesMatcher ("indices:bar" ).test (mockIndexAbstraction (index )), is (false ));
554
- assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (mockIndexAbstraction (index )), is (false ));
555
554
assertThat (kibanaRole .indices ().allowedIndicesMatcher (GetIndexAction .NAME ).test (mockIndexAbstraction (index )), is (true ));
556
555
assertThat (kibanaRole .indices ().allowedIndicesMatcher (CreateIndexAction .NAME ).test (mockIndexAbstraction (index )), is (false ));
557
556
assertThat (kibanaRole .indices ().allowedIndicesMatcher (IndexAction .NAME ).test (mockIndexAbstraction (index )), is (false ));
@@ -565,6 +564,8 @@ public void testKibanaSystemRole() {
565
564
assertThat (kibanaRole .indices ().allowedIndicesMatcher (UpdateSettingsAction .NAME ).test (mockIndexAbstraction (index )), is (true ));
566
565
assertThat (kibanaRole .indices ().allowedIndicesMatcher (PutMappingAction .NAME ).test (mockIndexAbstraction (index )), is (true ));
567
566
assertThat (kibanaRole .indices ().allowedIndicesMatcher (RolloverAction .NAME ).test (mockIndexAbstraction (index )), is (true ));
567
+ // Privileges needed for installing current ILM policy with delete action
568
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (mockIndexAbstraction (index )), is (true ));
568
569
});
569
570
570
571
Arrays .asList (
@@ -708,7 +709,6 @@ public void testKibanaSystemRole() {
708
709
assertThat (kibanaRole .indices ().allowedIndicesMatcher (CreateIndexAction .NAME ).test (indexAbstraction ), is (false ));
709
710
assertThat (kibanaRole .indices ().allowedIndicesMatcher (AutoCreateAction .NAME ).test (indexAbstraction ), is (false ));
710
711
assertThat (kibanaRole .indices ().allowedIndicesMatcher (CreateDataStreamAction .NAME ).test (indexAbstraction ), is (false ));
711
- assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (indexAbstraction ), is (false ));
712
712
assertThat (kibanaRole .indices ().allowedIndicesMatcher (IndexAction .NAME ).test (indexAbstraction ), is (false ));
713
713
assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteAction .NAME ).test (indexAbstraction ), is (false ));
714
714
@@ -717,6 +717,11 @@ public void testKibanaSystemRole() {
717
717
assertThat (kibanaRole .indices ().allowedIndicesMatcher (GetAction .NAME ).test (indexAbstraction ), is (isAlsoReadIndex ));
718
718
assertThat (kibanaRole .indices ().allowedIndicesMatcher (SearchAction .NAME ).test (indexAbstraction ), is (isAlsoReadIndex ));
719
719
assertThat (kibanaRole .indices ().allowedIndicesMatcher (MultiSearchAction .NAME ).test (indexAbstraction ), is (isAlsoReadIndex ));
720
+
721
+ // Endpoint diagnostic and sampled traces data streams also have an ILM policy with a delete action, all others should not.
722
+ final boolean isAlsoIlmDeleteIndex = indexName .startsWith (".logs-endpoint.diagnostic.collection-" )
723
+ || indexName .startsWith ("traces-apm.sampled-" );
724
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (indexAbstraction ), is (isAlsoIlmDeleteIndex ));
720
725
});
721
726
722
727
// 4. Transform for endpoint package
@@ -782,6 +787,31 @@ public void testKibanaSystemRole() {
782
787
assertThat (kibanaRole .indices ().allowedIndicesMatcher (UpdateSettingsAction .NAME ).test (indexAbstraction ), is (false ));
783
788
assertThat (kibanaRole .indices ().allowedIndicesMatcher (RolloverAction .NAME ).test (indexAbstraction ), is (false ));
784
789
});
790
+
791
+ // Ensure privileges necessary for ILM policies in APM & Endpoint packages
792
+ Arrays .asList (
793
+ "metrics-apm.app-" + randomAlphaOfLengthBetween (3 , 8 ),
794
+ "metrics-apm.internal-" + randomAlphaOfLengthBetween (3 , 8 ),
795
+ "metrics-apm.profiling-" + randomAlphaOfLengthBetween (3 , 8 ),
796
+ "logs-apm.error_logs-" + randomAlphaOfLengthBetween (3 , 8 ),
797
+ "traces-apm-" + randomAlphaOfLengthBetween (3 , 8 )
798
+ ).forEach (indexName -> {
799
+ logger .info ("index name [{}]" , indexName );
800
+ final IndexAbstraction indexAbstraction = mockIndexAbstraction (indexName );
801
+
802
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (UpdateSettingsAction .NAME ).test (indexAbstraction ), is (true ));
803
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (RolloverAction .NAME ).test (indexAbstraction ), is (true ));
804
+ });
805
+ Arrays .asList (
806
+ ".logs-endpoint.diagnostic.collection-" + randomAlphaOfLengthBetween (3 , 8 ),
807
+ "traces-apm.sampled-" + randomAlphaOfLengthBetween (3 , 8 )
808
+ ).forEach (indexName -> {
809
+ logger .info ("index name [{}]" , indexName );
810
+ final IndexAbstraction indexAbstraction = mockIndexAbstraction (indexName );
811
+
812
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (DeleteIndexAction .NAME ).test (indexAbstraction ), is (true ));
813
+ assertThat (kibanaRole .indices ().allowedIndicesMatcher (RolloverAction .NAME ).test (indexAbstraction ), is (true ));
814
+ });
785
815
}
786
816
787
817
public void testKibanaAdminRole () {
0 commit comments