@@ -224,7 +224,7 @@ public void testFailureStoreAccess() throws IOException {
224224 }""" ), manageFailureStoreRole );
225225
226226 createTemplates ();
227- List <String > docIds = populateDataStreamWithBulkRequest ();
227+ List <String > docIds = populateDataStream ();
228228 assertThat (docIds .size (), equalTo (2 ));
229229 assertThat (docIds , hasItem ("1" ));
230230 String successDocId = "1" ;
@@ -352,6 +352,8 @@ public void testFailureStoreAccess() throws IOException {
352352 expectThrows (() -> deleteIndex (MANAGE_FAILURE_STORE_ACCESS_USER , failureIndexName ), 400 );
353353 expectThrows403 (() -> deleteDataStream (MANAGE_FAILURE_STORE_ACCESS_USER , dataIndexName ));
354354
355+ expectThrows (() -> deleteDataStream (MANAGE_FAILURE_STORE_ACCESS_USER , "test1" ), 403 );
356+ expectThrows (() -> deleteDataStream (MANAGE_FAILURE_STORE_ACCESS_USER , "test1::failures" ), 403 );
355357 // manage user can delete data stream
356358 deleteDataStream (MANAGE_ACCESS_USER , "test1" );
357359
@@ -440,6 +442,34 @@ private void createTemplates() throws IOException {
440442 assertOK (adminClient ().performRequest (indexTemplateRequest ));
441443 }
442444
445+ private List <String > populateDataStream () throws IOException {
446+ return randomBoolean () ? populateDataStreamWithBulkRequest () : populateDataStreamWithDocRequests ();
447+ }
448+
449+ @ SuppressWarnings ("unchecked" )
450+ private List <String > populateDataStreamWithDocRequests () throws IOException {
451+ var bulkRequest = new Request ("POST" , "/_bulk?refresh=true" );
452+ bulkRequest .setJsonEntity ("""
453+ { "create" : { "_index" : "test1", "_id" : "1" } }
454+ { "@timestamp": 1, "age" : 1, "name" : "jack", "email" : "[email protected] " } 455+ { "create" : { "_index" : "test1", "_id" : "2" } }
456+ { "@timestamp": 2, "age" : "this should be an int", "name" : "jack", "email" : "[email protected] " } 457+ """ );
458+ Response response = performRequest (WRITE_ACCESS_USER , bulkRequest );
459+ assertOK (response );
460+ // we need this dance because the ID for the failed document is random, **not** 2
461+ Map <String , Object > stringObjectMap = responseAsMap (response );
462+ List <Object > items = (List <Object >) stringObjectMap .get ("items" );
463+ List <String > ids = new ArrayList <>();
464+ for (Object item : items ) {
465+ Map <String , Object > itemMap = (Map <String , Object >) item ;
466+ Map <String , Object > create = (Map <String , Object >) itemMap .get ("create" );
467+ assertThat (create .get ("status" ), equalTo (201 ));
468+ ids .add ((String ) create .get ("_id" ));
469+ }
470+ return ids ;
471+ }
472+
443473 @ SuppressWarnings ("unchecked" )
444474 private List <String > populateDataStreamWithBulkRequest () throws IOException {
445475 var bulkRequest = new Request ("POST" , "/_bulk?refresh=true" );
0 commit comments