|
@@ -17,12 +17,15 @@ import org.elasticsearch.action.search.SearchAction;
|
|
|
import org.elasticsearch.action.update.UpdateAction;
|
|
|
import org.elasticsearch.common.util.iterable.Iterables;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
+import org.elasticsearch.transport.TcpTransport;
|
|
|
import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
|
|
|
import org.elasticsearch.xpack.core.transform.action.GetCheckpointAction;
|
|
|
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static org.elasticsearch.xpack.core.security.authz.privilege.IndexPrivilege.findPrivilegesThatGrant;
|
|
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
@@ -65,7 +68,11 @@ public class IndexPrivilegeTests extends ESTestCase {
|
|
|
assertThat(findPrivilegesThatGrant(DeleteAction.NAME), equalTo(List.of("delete", "write", "all")));
|
|
|
assertThat(
|
|
|
findPrivilegesThatGrant(IndicesStatsAction.NAME),
|
|
|
- equalTo(List.of("monitor", "cross_cluster_replication", "manage", "all"))
|
|
|
+ equalTo(
|
|
|
+ Stream.of("monitor", (TcpTransport.isUntrustedRemoteClusterEnabled() ? "cross_cluster_replication" : null), "manage", "all")
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .toList()
|
|
|
+ )
|
|
|
);
|
|
|
assertThat(findPrivilegesThatGrant(RefreshAction.NAME), equalTo(List.of("maintenance", "manage", "all")));
|
|
|
assertThat(findPrivilegesThatGrant(ShrinkAction.NAME), equalTo(List.of("manage", "all")));
|
|
@@ -115,6 +122,8 @@ public class IndexPrivilegeTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCrossClusterReplicationPrivileges() {
|
|
|
+ assumeTrue("untrusted remote cluster feature flag must be enabled", TcpTransport.isUntrustedRemoteClusterEnabled());
|
|
|
+
|
|
|
final IndexPrivilege crossClusterReplication = IndexPrivilege.get(Set.of("cross_cluster_replication"));
|
|
|
List.of(
|
|
|
"indices:data/read/xpack/ccr/shard_changes",
|