3030import org .elasticsearch .action .search .TransportMultiSearchAction ;
3131import org .elasticsearch .action .search .TransportSearchAction ;
3232import org .elasticsearch .action .search .TransportSearchShardsAction ;
33+ import org .elasticsearch .action .support .IndexComponentSelector ;
3334import org .elasticsearch .action .support .IndicesOptions ;
3435import org .elasticsearch .action .support .PlainActionFuture ;
3536import org .elasticsearch .action .termvectors .MultiTermVectorsRequest ;
@@ -2233,14 +2234,14 @@ public void testDataStreamsAreNotVisibleWhenNotIncludedByRequestWithWildcard() {
22332234 List <String > dataStreams = List .of ("logs-foo" , "logs-foobar" );
22342235 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
22352236 for (String dsName : dataStreams ) {
2236- assertThat (authorizedIndices .all (null ), hasItem (dsName ));
2237- assertThat (authorizedIndices .check (dsName , null ), is (true ));
2237+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dsName ));
2238+ assertThat (authorizedIndices .check (dsName , IndexComponentSelector . DATA ), is (true ));
22382239 DataStream dataStream = projectMetadata .dataStreams ().get (dsName );
2239- assertThat (authorizedIndices .all (null ), hasItem (dsName ));
2240- assertThat (authorizedIndices .check (dsName , null ), is (true ));
2240+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dsName ));
2241+ assertThat (authorizedIndices .check (dsName , IndexComponentSelector . DATA ), is (true ));
22412242 for (Index i : dataStream .getIndices ()) {
2242- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2243- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2243+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2244+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
22442245 }
22452246 }
22462247
@@ -2272,14 +2273,14 @@ public void testDataStreamsAreNotVisibleWhenNotIncludedByRequestWithoutWildcard(
22722273 // data streams and their backing indices should _not_ be in the authorized list since the backing indices
22732274 // do not match the requested name
22742275 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2275- assertThat (authorizedIndices .all (null ), hasItem (dataStreamName ));
2276- assertThat (authorizedIndices .check (dataStreamName , null ), is (true ));
2276+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dataStreamName ));
2277+ assertThat (authorizedIndices .check (dataStreamName , IndexComponentSelector . DATA ), is (true ));
22772278 DataStream dataStream = projectMetadata .dataStreams ().get (dataStreamName );
2278- assertThat (authorizedIndices .all (null ), hasItem (dataStreamName ));
2279- assertThat (authorizedIndices .check (dataStreamName , null ), is (true ));
2279+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dataStreamName ));
2280+ assertThat (authorizedIndices .check (dataStreamName , IndexComponentSelector . DATA ), is (true ));
22802281 for (Index i : dataStream .getIndices ()) {
2281- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2282- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2282+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2283+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
22832284 }
22842285
22852286 // neither data streams nor their backing indices will be in the resolved list since the backing indices do not match the
@@ -2307,11 +2308,11 @@ public void testDataStreamsAreVisibleWhenIncludedByRequestWithWildcard() {
23072308 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , TransportSearchAction .TYPE .name (), request );
23082309 for (String dsName : expectedDataStreams ) {
23092310 DataStream dataStream = projectMetadata .dataStreams ().get (dsName );
2310- assertThat (authorizedIndices .all (null ), hasItem (dsName ));
2311- assertThat (authorizedIndices .check (dsName , null ), is (true ));
2311+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dsName ));
2312+ assertThat (authorizedIndices .check (dsName , IndexComponentSelector . DATA ), is (true ));
23122313 for (Index i : dataStream .getIndices ()) {
2313- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2314- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2314+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2315+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
23152316 }
23162317 }
23172318
@@ -2348,11 +2349,11 @@ public void testDataStreamsAreVisibleWhenIncludedByRequestWithoutWildcard() {
23482349
23492350 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , TransportSearchAction .TYPE .name (), request );
23502351 // data streams and their backing indices should be in the authorized list
2351- assertThat (authorizedIndices .all (null ), hasItem (dataStreamName ));
2352- assertThat (authorizedIndices .check (dataStreamName , null ), is (true ));
2352+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dataStreamName ));
2353+ assertThat (authorizedIndices .check (dataStreamName , IndexComponentSelector . DATA ), is (true ));
23532354 for (Index i : dataStream .getIndices ()) {
2354- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2355- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2355+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2356+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
23562357 }
23572358
23582359 ResolvedIndices resolvedIndices = defaultIndicesResolver .resolveIndicesAndAliases (
@@ -2381,15 +2382,15 @@ public void testBackingIndicesAreVisibleWhenIncludedByRequestWithWildcard() {
23812382 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , TransportSearchAction .TYPE .name (), request );
23822383 for (String dsName : expectedDataStreams ) {
23832384 DataStream dataStream = projectMetadata .dataStreams ().get (dsName );
2384- assertThat (authorizedIndices .all (null ), hasItem (dsName ));
2385- assertThat (authorizedIndices .check (dsName , null ), is (true ));
2385+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dsName ));
2386+ assertThat (authorizedIndices .check (dsName , IndexComponentSelector . DATA ), is (true ));
23862387 for (Index i : dataStream .getIndices ()) {
2387- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2388- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2388+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2389+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
23892390 }
23902391 for (Index i : dataStream .getFailureIndices ()) {
2391- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2392- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2392+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2393+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
23932394 }
23942395 }
23952396
@@ -2420,16 +2421,16 @@ public void testBackingIndicesAreNotVisibleWhenNotIncludedByRequestWithoutWildca
24202421 // data streams and their backing indices should _not_ be in the authorized list since the backing indices
24212422 // did not match the requested pattern and the request does not support data streams
24222423 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2423- assertThat (authorizedIndices .all (null ), hasItem (dataStreamName ));
2424- assertThat (authorizedIndices .check (dataStreamName , null ), is (true ));
2424+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (dataStreamName ));
2425+ assertThat (authorizedIndices .check (dataStreamName , IndexComponentSelector . DATA ), is (true ));
24252426 DataStream dataStream = projectMetadata .dataStreams ().get (dataStreamName );
24262427 for (Index i : dataStream .getIndices ()) {
2427- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2428- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2428+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2429+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
24292430 }
24302431 for (Index i : dataStream .getFailureIndices ()) {
2431- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2432- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2432+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2433+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
24332434 }
24342435
24352436 // neither data streams nor their backing indices will be in the resolved list since the request does not support data streams
@@ -2460,19 +2461,19 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaWildcar
24602461 // data streams should _not_ be in the authorized list but their backing indices that matched both the requested pattern
24612462 // and the authorized pattern should be in the list
24622463 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2463- assertThat (authorizedIndices .all (null ), not (hasItem ("logs-foobar" )));
2464- assertThat (authorizedIndices .check ("logs-foobar" , null ), is (false ));
2464+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem ("logs-foobar" )));
2465+ assertThat (authorizedIndices .check ("logs-foobar" , IndexComponentSelector . DATA ), is (false ));
24652466 DataStream dataStream = projectMetadata .dataStreams ().get ("logs-foobar" );
2466- assertThat (authorizedIndices .all (null ), not (hasItem (indexName )));
2467+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem (indexName )));
24672468 // request pattern is subset of the authorized pattern, but be aware that patterns are never passed to #check in main code
2468- assertThat (authorizedIndices .check (indexName , null ), is (true ));
2469+ assertThat (authorizedIndices .check (indexName , IndexComponentSelector . DATA ), is (true ));
24692470 for (Index i : dataStream .getIndices ()) {
2470- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2471- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2471+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2472+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
24722473 }
24732474 for (Index i : dataStream .getFailureIndices ()) {
2474- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2475- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2475+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2476+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
24762477 }
24772478
24782479 // only the backing indices will be in the resolved list since the request does not support data streams
@@ -2500,14 +2501,14 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaNameAnd
25002501 // data streams should _not_ be in the authorized list but a single backing index that matched the requested pattern
25012502 // and the authorized name should be in the list
25022503 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2503- assertThat (authorizedIndices .all (null ), not (hasItem ("logs-foobar" )));
2504- assertThat (authorizedIndices .check ("logs-foobar" , null ), is (false ));
2504+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem ("logs-foobar" )));
2505+ assertThat (authorizedIndices .check ("logs-foobar" , IndexComponentSelector . DATA ), is (false ));
25052506
25062507 String expectedIndex = failureStore
25072508 ? DataStream .getDefaultFailureStoreName ("logs-foobar" , 1 , System .currentTimeMillis ())
25082509 : DataStream .getDefaultBackingIndexName ("logs-foobar" , 1 );
2509- assertThat (authorizedIndices .all (null ), hasItem (expectedIndex ));
2510- assertThat (authorizedIndices .check (expectedIndex , null ), is (true ));
2510+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (expectedIndex ));
2511+ assertThat (authorizedIndices .check (expectedIndex , IndexComponentSelector . DATA ), is (true ));
25112512
25122513 // only the single backing index will be in the resolved list since the request does not support data streams
25132514 // but one of the backing indices matched the requested pattern
@@ -2532,19 +2533,19 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaWildcar
25322533 // data streams should _not_ be in the authorized list but their backing indices that matched both the requested pattern
25332534 // and the authorized pattern should be in the list
25342535 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2535- assertThat (authorizedIndices .all (null ), not (hasItem ("logs-foobar" )));
2536- assertThat (authorizedIndices .check ("logs-foobar" , null ), is (false ));
2536+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem ("logs-foobar" )));
2537+ assertThat (authorizedIndices .check ("logs-foobar" , IndexComponentSelector . DATA ), is (false ));
25372538 DataStream dataStream = projectMetadata .dataStreams ().get ("logs-foobar" );
2538- assertThat (authorizedIndices .all (null ), not (hasItem (indexName )));
2539+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem (indexName )));
25392540 // request pattern is subset of the authorized pattern, but be aware that patterns are never passed to #check in main code
2540- assertThat (authorizedIndices .check (indexName , null ), is (true ));
2541+ assertThat (authorizedIndices .check (indexName , IndexComponentSelector . DATA ), is (true ));
25412542 for (Index i : dataStream .getIndices ()) {
2542- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2543- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2543+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2544+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
25442545 }
25452546 for (Index i : dataStream .getFailureIndices ()) {
2546- assertThat (authorizedIndices .all (null ), hasItem (i .getName ()));
2547- assertThat (authorizedIndices .check (i .getName (), null ), is (true ));
2547+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (i .getName ()));
2548+ assertThat (authorizedIndices .check (i .getName (), IndexComponentSelector . DATA ), is (true ));
25482549 }
25492550
25502551 // only the backing indices will be in the resolved list since the request does not support data streams
@@ -2575,10 +2576,10 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaNameAnd
25752576 ? DataStream .getDefaultFailureStoreName ("logs-foobar" , 1 , System .currentTimeMillis ())
25762577 : DataStream .getDefaultBackingIndexName ("logs-foobar" , 1 );
25772578 final AuthorizedIndices authorizedIndices = buildAuthorizedIndices (user , GetAliasesAction .NAME , request );
2578- assertThat (authorizedIndices .all (null ), not (hasItem ("logs-foobar" )));
2579- assertThat (authorizedIndices .check ("logs-foobar" , null ), is (false ));
2580- assertThat (authorizedIndices .all (null ), hasItem (expectedIndex ));
2581- assertThat (authorizedIndices .check (expectedIndex , null ), is (true ));
2579+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), not (hasItem ("logs-foobar" )));
2580+ assertThat (authorizedIndices .check ("logs-foobar" , IndexComponentSelector . DATA ), is (false ));
2581+ assertThat (authorizedIndices .all (IndexComponentSelector . DATA ), hasItem (expectedIndex ));
2582+ assertThat (authorizedIndices .check (expectedIndex , IndexComponentSelector . DATA ), is (true ));
25822583
25832584 // only the single backing index will be in the resolved list since the request does not support data streams
25842585 // but one of the backing indices matched the requested pattern
0 commit comments