113113
114114import static org .elasticsearch .action .ResolvedIndexExpression .LocalIndexResolutionResult .CONCRETE_RESOURCE_NOT_VISIBLE ;
115115import static org .elasticsearch .action .ResolvedIndexExpression .LocalIndexResolutionResult .CONCRETE_RESOURCE_UNAUTHORIZED ;
116+ import static org .elasticsearch .action .ResolvedIndexExpression .LocalIndexResolutionResult .NONE ;
116117import static org .elasticsearch .action .ResolvedIndexExpression .LocalIndexResolutionResult .SUCCESS ;
117118import static org .elasticsearch .cluster .metadata .DataStreamTestHelper .newInstance ;
118119import static org .elasticsearch .test .ActionListenerUtils .anyActionListener ;
@@ -2985,7 +2986,7 @@ public void testResolveAllWithWildcardRemotePrefix() {
29852986 );
29862987 }
29872988
2988- public void testResolveAllWithRemotePrefix () {
2989+ public void testResolveAllWithLocalPrefix () {
29892990 when (crossProjectModeDecider .resolvesCrossProject (any (IndicesRequest .Replaceable .class ))).thenReturn (true );
29902991
29912992 var expression = randomBoolean () ? "local:_all" : "_origin:_all" ;
@@ -3012,6 +3013,33 @@ public void testResolveAllWithRemotePrefix() {
30123013 assertThat (resolved .expressions (), contains (resolvedIndexExpression (expression , Set .of (expectedIndices ), SUCCESS , Set .of ())));
30133014 }
30143015
3016+ public void testResolveAllWithRemotePrefix () {
3017+ when (crossProjectModeDecider .resolvesCrossProject (any (IndicesRequest .Replaceable .class ))).thenReturn (true );
3018+
3019+ var request = new SearchRequest ().indices ("P*:_all" );
3020+ request .indicesOptions (IndicesOptions .fromOptions (randomBoolean (), randomBoolean (), true , true ));
3021+ var resolvedIndices = defaultIndicesResolver .resolveIndicesAndAliases (
3022+ "indices:/" + randomAlphaOfLength (8 ),
3023+ request ,
3024+ projectMetadata ,
3025+ buildAuthorizedIndices (user , TransportSearchAction .TYPE .name ()),
3026+ new TargetProjects (
3027+ createRandomProjectWithAlias ("local" ),
3028+ List .of (createRandomProjectWithAlias ("P1" ), createRandomProjectWithAlias ("P2" ), createRandomProjectWithAlias ("P3" ))
3029+ )
3030+ );
3031+
3032+ assertThat (resolvedIndices .getLocal (), is (empty ()));
3033+ assertThat (resolvedIndices .getRemote (), contains ("P1:_all" , "P2:_all" , "P3:_all" ));
3034+
3035+ final var resolved = request .getResolvedIndexExpressions ();
3036+ assertThat (resolved , is (notNullValue ()));
3037+ assertThat (
3038+ resolved .expressions (),
3039+ contains (resolvedIndexExpression ("P*:_all" , Set .of (), NONE , Set .of ("P1:_all" , "P2:_all" , "P3:_all" )))
3040+ );
3041+ }
3042+
30153043 public void testResolveIndexWithRemotePrefix () {
30163044 when (crossProjectModeDecider .resolvesCrossProject (any (IndicesRequest .Replaceable .class ))).thenReturn (true );
30173045
0 commit comments