14
14
import org .elasticsearch .cluster .metadata .IndexAbstraction ;
15
15
import org .elasticsearch .cluster .metadata .IndexAbstraction .ConcreteIndex ;
16
16
import org .elasticsearch .cluster .metadata .IndexMetadata ;
17
+ import org .elasticsearch .cluster .metadata .Metadata ;
17
18
import org .elasticsearch .common .settings .Settings ;
18
19
import org .elasticsearch .index .IndexVersion ;
19
20
import org .elasticsearch .test .ESTestCase ;
31
32
import java .util .Collections ;
32
33
import java .util .HashMap ;
33
34
import java .util .Map ;
35
+ import java .util .stream .Stream ;
34
36
35
37
import static org .hamcrest .Matchers .is ;
36
38
@@ -117,12 +119,13 @@ public void testAuthorizeClusterAction() {
117
119
118
120
public void testAuthorizeIndexAction () {
119
121
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 ();
126
129
// authorized
127
130
{
128
131
RequestInfo requestInfo =
@@ -136,7 +139,7 @@ public void testAuthorizeIndexAction() {
136
139
PlainActionFuture <IndexAuthorizationResult > resultFuture = new PlainActionFuture <>();
137
140
engine .authorizeIndexAction (requestInfo , authzInfo ,
138
141
listener -> listener .onResponse (new ResolvedIndices (Collections .singletonList ("index" ), Collections .emptyList ())),
139
- indicesMap , resultFuture );
142
+ metadata , resultFuture );
140
143
IndexAuthorizationResult result = resultFuture .actionGet ();
141
144
assertThat (result .isGranted (), is (true ));
142
145
IndicesAccessControl indicesAccessControl = result .getIndicesAccessControl ();
@@ -156,7 +159,7 @@ public void testAuthorizeIndexAction() {
156
159
PlainActionFuture <IndexAuthorizationResult > resultFuture = new PlainActionFuture <>();
157
160
engine .authorizeIndexAction (requestInfo , authzInfo ,
158
161
listener -> listener .onResponse (new ResolvedIndices (Collections .singletonList ("index" ), Collections .emptyList ())),
159
- indicesMap , resultFuture );
162
+ metadata , resultFuture );
160
163
IndexAuthorizationResult result = resultFuture .actionGet ();
161
164
assertThat (result .isGranted (), is (false ));
162
165
IndicesAccessControl indicesAccessControl = result .getIndicesAccessControl ();
0 commit comments