Skip to content

Commit 400a1f7

Browse files
committed
Fix
1 parent be718df commit 400a1f7

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

server/src/test/java/org/elasticsearch/cluster/metadata/IndexAbstractionResolverTests.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.List;
2828
import java.util.Set;
2929
import java.util.concurrent.TimeUnit;
30-
import java.util.function.Supplier;
3130

3231
import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME;
3332
import static org.elasticsearch.indices.SystemIndices.EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY;
@@ -48,7 +47,7 @@ public class IndexAbstractionResolverTests extends ESTestCase {
4847
private String dateTimeIndexTomorrow;
4948

5049
// Only used when resolving wildcard expressions
51-
private final Supplier<Set<String>> defaultMask = () -> Set.of("index1", "index2", "data-stream1");
50+
private final Set<String> defaultMask = Set.of("index1", "index2", "data-stream1");
5251

5352
@Override
5453
public void setUp() throws Exception {
@@ -215,13 +214,11 @@ public void testResolveIndexAbstractions() {
215214

216215
public void testIsIndexVisible() {
217216
assertThat(isIndexVisible("index1", null), is(true));
218-
assertThat(isIndexVisible("index1", "*"), is(true));
219217
assertThat(isIndexVisible("index1", "data"), is(true));
220218
assertThat(isIndexVisible("index1", "failures"), is(false)); // *
221219
// * Indices don't have failure components so the failure component is not visible
222220

223221
assertThat(isIndexVisible("data-stream1", null), is(true));
224-
assertThat(isIndexVisible("data-stream1", "*"), is(true));
225222
assertThat(isIndexVisible("data-stream1", "data"), is(true));
226223
assertThat(isIndexVisible("data-stream1", "failures"), is(true));
227224
}
@@ -290,14 +287,14 @@ public void testIsNetNewSystemIndexVisible() {
290287
indexAbstractionResolver = new IndexAbstractionResolver(indexNameExpressionResolver);
291288

292289
// this covers the GET * case -- with system access, you can see everything
293-
assertThat(isIndexVisible("other", "*"), is(true));
294-
assertThat(isIndexVisible(".foo", "*"), is(true));
295-
assertThat(isIndexVisible(".bar", "*"), is(true));
290+
assertThat(isIndexVisible("other", null), is(true));
291+
assertThat(isIndexVisible(".foo", null), is(true));
292+
assertThat(isIndexVisible(".bar", null), is(true));
296293

297294
// but if you don't ask for hidden and aliases, you won't see hidden indices or aliases, naturally
298-
assertThat(isIndexVisible("other", "*", noHiddenNoAliases), is(true));
299-
assertThat(isIndexVisible(".foo", "*", noHiddenNoAliases), is(false));
300-
assertThat(isIndexVisible(".bar", "*", noHiddenNoAliases), is(false));
295+
assertThat(isIndexVisible("other", null, noHiddenNoAliases), is(true));
296+
assertThat(isIndexVisible(".foo", null, noHiddenNoAliases), is(false));
297+
assertThat(isIndexVisible(".bar", null, noHiddenNoAliases), is(false));
301298
}
302299

303300
{
@@ -311,14 +308,14 @@ public void testIsNetNewSystemIndexVisible() {
311308
indexAbstractionResolver = new IndexAbstractionResolver(indexNameExpressionResolver);
312309

313310
// this covers the GET * case -- without system access, you can't see everything
314-
assertThat(isIndexVisible("other", "*"), is(true));
315-
assertThat(isIndexVisible(".foo", "*"), is(false));
316-
assertThat(isIndexVisible(".bar", "*"), is(false));
311+
assertThat(isIndexVisible("other", null), is(true));
312+
assertThat(isIndexVisible(".foo", null), is(false));
313+
assertThat(isIndexVisible(".bar", null), is(false));
317314

318315
// no difference here in the datastream case, you can't see these then, either
319-
assertThat(isIndexVisible("other", "*", noHiddenNoAliases), is(true));
320-
assertThat(isIndexVisible(".foo", "*", noHiddenNoAliases), is(false));
321-
assertThat(isIndexVisible(".bar", "*", noHiddenNoAliases), is(false));
316+
assertThat(isIndexVisible("other", null, noHiddenNoAliases), is(true));
317+
assertThat(isIndexVisible(".foo", null, noHiddenNoAliases), is(false));
318+
assertThat(isIndexVisible(".bar", null, noHiddenNoAliases), is(false));
322319
}
323320

324321
{
@@ -333,14 +330,14 @@ public void testIsNetNewSystemIndexVisible() {
333330
indexAbstractionResolver = new IndexAbstractionResolver(indexNameExpressionResolver);
334331

335332
// this covers the GET * case -- with product (only) access, you can't see everything
336-
assertThat(isIndexVisible("other", "*"), is(true));
337-
assertThat(isIndexVisible(".foo", "*"), is(false));
338-
assertThat(isIndexVisible(".bar", "*"), is(false));
333+
assertThat(isIndexVisible("other", null), is(true));
334+
assertThat(isIndexVisible(".foo", null), is(false));
335+
assertThat(isIndexVisible(".bar", null), is(false));
339336

340337
// no difference here in the datastream case, you can't see these then, either
341-
assertThat(isIndexVisible("other", "*", noHiddenNoAliases), is(true));
342-
assertThat(isIndexVisible(".foo", "*", noHiddenNoAliases), is(false));
343-
assertThat(isIndexVisible(".bar", "*", noHiddenNoAliases), is(false));
338+
assertThat(isIndexVisible("other", null, noHiddenNoAliases), is(true));
339+
assertThat(isIndexVisible(".foo", null, noHiddenNoAliases), is(false));
340+
assertThat(isIndexVisible(".bar", null, noHiddenNoAliases), is(false));
344341
}
345342
}
346343

@@ -366,14 +363,13 @@ private List<String> resolveAbstractionsSelectorAllowed(List<String> expressions
366363
return resolveAbstractions(expressions, IndicesOptions.strictExpandOpen(), defaultMask);
367364
}
368365

369-
private List<String> resolveAbstractions(List<String> expressions, IndicesOptions indicesOptions, Supplier<Set<String>> mask) {
366+
private List<String> resolveAbstractions(List<String> expressions, IndicesOptions indicesOptions, Set<String> mask) {
370367
return indexAbstractionResolver.resolveIndexAbstractions(
371368
expressions,
372369
indicesOptions,
373370
projectMetadata,
374-
// TODO
375-
sel -> mask,
376-
(idx, sel) -> true,
371+
(ignored) -> mask,
372+
(ignored, nothing) -> true,
377373
true
378374
);
379375
}

0 commit comments

Comments
 (0)