|
14 | 14 | import org.elasticsearch.xpack.core.security.authz.privilege.ClusterPrivilegeResolver; |
15 | 15 | import org.elasticsearch.xpack.core.security.authz.privilege.ConfigurableClusterPrivilege; |
16 | 16 | import org.elasticsearch.xpack.core.security.authz.privilege.ConfigurableClusterPrivileges; |
| 17 | +import org.elasticsearch.xpack.core.security.authz.privilege.IndexComponentSelectorPredicate; |
17 | 18 | import org.elasticsearch.xpack.core.security.authz.privilege.IndexPrivilege; |
18 | 19 | import org.elasticsearch.xpack.core.security.support.MetadataUtils; |
19 | 20 |
|
|
23 | 24 | import java.util.List; |
24 | 25 | import java.util.Map; |
25 | 26 | import java.util.Set; |
| 27 | +import java.util.stream.Collectors; |
26 | 28 |
|
27 | 29 | import static org.elasticsearch.test.ESTestCase.generateRandomStringArray; |
28 | 30 | import static org.elasticsearch.test.ESTestCase.randomAlphaOfLengthBetween; |
@@ -128,10 +130,14 @@ public static ConfigurableClusterPrivilege[] randomManageRolesPrivileges() { |
128 | 130 | () -> { |
129 | 131 | String[] indexPatterns = randomArray(1, 5, String[]::new, () -> randomAlphaOfLengthBetween(5, 100)); |
130 | 132 |
|
131 | | - int startIndex = randomIntBetween(0, IndexPrivilege.names().size() - 2); |
132 | | - int endIndex = randomIntBetween(startIndex + 1, IndexPrivilege.names().size()); |
| 133 | + Set<String> validNames = IndexPrivilege.names().stream().filter(p -> { |
| 134 | + IndexPrivilege named = IndexPrivilege.getNamedOrNull(p); |
| 135 | + return named != null && named.getSelectorPredicate() != IndexComponentSelectorPredicate.FAILURES; |
| 136 | + }).collect(Collectors.toSet()); |
| 137 | + int startIndex = randomIntBetween(0, validNames.size() - 2); |
| 138 | + int endIndex = randomIntBetween(startIndex + 1, validNames.size()); |
133 | 139 |
|
134 | | - String[] indexPrivileges = IndexPrivilege.names().stream().toList().subList(startIndex, endIndex).toArray(String[]::new); |
| 140 | + String[] indexPrivileges = validNames.stream().toList().subList(startIndex, endIndex).toArray(String[]::new); |
135 | 141 | return new ConfigurableClusterPrivileges.ManageRolesPrivilege.ManageRolesIndexPermissionGroup( |
136 | 142 | indexPatterns, |
137 | 143 | indexPrivileges |
|
0 commit comments