1414import  org .elasticsearch .cluster .metadata .IndexAbstraction ;
1515import  org .elasticsearch .cluster .metadata .IndexAbstraction .ConcreteIndex ;
1616import  org .elasticsearch .cluster .metadata .IndexMetadata ;
17+ import  org .elasticsearch .cluster .metadata .Metadata ;
1718import  org .elasticsearch .common .settings .Settings ;
1819import  org .elasticsearch .index .IndexVersion ;
1920import  org .elasticsearch .test .ESTestCase ;
3132import  java .util .Collections ;
3233import  java .util .HashMap ;
3334import  java .util .Map ;
35+ import  java .util .stream .Stream ;
3436
3537import  static  org .hamcrest .Matchers .is ;
3638
@@ -117,12 +119,13 @@ public void testAuthorizeClusterAction() {
117119
118120    public  void  testAuthorizeIndexAction () {
119121        CustomAuthorizationEngine  engine  = new  CustomAuthorizationEngine ();
120-         Map <String , IndexAbstraction > indicesMap  = new  HashMap <>();
121-         indicesMap .put ("index" , new  ConcreteIndex (IndexMetadata .builder ("index" )
122-             .settings (Settings .builder ().put ("index.version.created" , IndexVersion .current ()))
123-             .numberOfShards (1 )
124-             .numberOfReplicas (0 )
125-             .build (), null ));
122+         Metadata  metadata  = Metadata .builder ().put (IndexMetadata .builder ("index" )
123+                 .settings (Settings .builder ().put ("index.version.created" , IndexVersion .current ()))
124+                 .numberOfShards (1 )
125+                 .numberOfReplicas (0 )
126+                 .build (),
127+                     false 
128+                 ).build ();
126129        // authorized 
127130        {
128131            RequestInfo  requestInfo  =
@@ -136,7 +139,7 @@ public void testAuthorizeIndexAction() {
136139            PlainActionFuture <IndexAuthorizationResult > resultFuture  = new  PlainActionFuture <>();
137140            engine .authorizeIndexAction (requestInfo , authzInfo ,
138141                listener  -> listener .onResponse (new  ResolvedIndices (Collections .singletonList ("index" ), Collections .emptyList ())),
139-                 indicesMap , resultFuture );
142+                 metadata , resultFuture );
140143            IndexAuthorizationResult  result  = resultFuture .actionGet ();
141144            assertThat (result .isGranted (), is (true ));
142145            IndicesAccessControl  indicesAccessControl  = result .getIndicesAccessControl ();
@@ -156,7 +159,7 @@ public void testAuthorizeIndexAction() {
156159            PlainActionFuture <IndexAuthorizationResult > resultFuture  = new  PlainActionFuture <>();
157160            engine .authorizeIndexAction (requestInfo , authzInfo ,
158161                listener  -> listener .onResponse (new  ResolvedIndices (Collections .singletonList ("index" ), Collections .emptyList ())),
159-                 indicesMap , resultFuture );
162+                 metadata , resultFuture );
160163            IndexAuthorizationResult  result  = resultFuture .actionGet ();
161164            assertThat (result .isGranted (), is (false ));
162165            IndicesAccessControl  indicesAccessControl  = result .getIndicesAccessControl ();
0 commit comments