Skip to content

Commit 4ca9978

Browse files
committed
Assert
1 parent d3f50dc commit 4ca9978

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/IndicesAccessControl.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.common.util.Maps;
1414
import org.elasticsearch.common.util.set.Sets;
1515
import org.elasticsearch.core.Nullable;
16-
import org.elasticsearch.core.Tuple;
1716
import org.elasticsearch.xpack.core.security.authz.IndicesAndAliasesResolverField;
1817
import org.elasticsearch.xpack.core.security.authz.permission.DocumentPermissions;
1918
import org.elasticsearch.xpack.core.security.authz.permission.FieldPermissions;
@@ -62,13 +61,10 @@ protected IndicesAccessControl(IndicesAccessControl copy) {
6261
*/
6362
@Nullable
6463
public IndexAccessControl getIndexPermissions(String index) {
65-
Tuple<String, String> indexAndSelector = IndexNameExpressionResolver.splitSelectorExpression(index);
66-
return this.getAllIndexPermissions()
67-
.get(
68-
IndexComponentSelector.FAILURES.equals(IndexComponentSelector.getByKey(indexAndSelector.v2()))
69-
? index
70-
: indexAndSelector.v1()
71-
);
64+
assert false == IndexNameExpressionResolver.hasSelectorSuffix(index)
65+
|| IndexNameExpressionResolver.hasSelector(index, IndexComponentSelector.FAILURES)
66+
: "index name [" + index + "] cannot have explicit selector other than ::failures";
67+
return getAllIndexPermissions().get(index);
7268
}
7369

7470
public boolean hasIndexPermissions(String index) {

x-pack/plugin/security/qa/security-trial/src/javaRestTest/java/org/elasticsearch/xpack/security/failurestore/FailureStoreSecurityRestIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public void testFailureStoreAccess() throws Exception {
418418

419419
// search data
420420
{
421-
var request = new Search("test1");
421+
var request = new Search(randomFrom("test1::data", "test1"));
422422
for (var user : users) {
423423
switch (user) {
424424
case DATA_ACCESS, STAR_READ_ONLY_ACCESS, BOTH_ACCESS:

0 commit comments

Comments
 (0)