Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Nov 14, 2024
1 parent 3a3c8a7 commit 626b881
Showing 1 changed file with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.xpack.core.security.authz.RoleDescriptor.SECURITY_ROLE_DESCRIPTION;
import static org.elasticsearch.xpack.core.security.authz.RoleDescriptor.WORKFLOWS_RESTRICTION_VERSION;
import static org.elasticsearch.xpack.core.security.authz.RoleDescriptorTestHelper.randomIndicesPrivileges;
import static org.elasticsearch.xpack.core.security.authz.RoleDescriptorTestHelper.randomIndicesPrivilegesBuilder;
import static org.elasticsearch.xpack.core.security.authz.RoleDescriptorTestHelper.randomRemoteClusterPermissions;
import static org.elasticsearch.xpack.core.security.authz.permission.RemoteClusterPermissions.ROLE_REMOTE_CLUSTER_PRIVS;
Expand All @@ -65,7 +63,6 @@
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.mockito.Mockito.mock;

public class RoleDescriptorTests extends ESTestCase {

Expand Down Expand Up @@ -1348,8 +1345,9 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
assertThat(
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]), //all of these are allowed
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]), // all of these are allowed
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
Expand All @@ -1366,8 +1364,9 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
assertThat(
new RoleDescriptor(
"name",
new String[]{"manage_security"}, // unlikely we will ever support allowing manage security across clusters
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new String[] { "manage_security" }, // unlikely we will ever support allowing manage security across clusters
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
Expand All @@ -1386,7 +1385,8 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
new ApplicationResourcePrivileges[] {
ApplicationResourcePrivileges.builder().application("app").privileges("foo").resources("res").build() },
null,
Expand All @@ -1406,11 +1406,11 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
new ConfigurableClusterPrivilege[] {
new ConfigurableClusterPrivileges.ManageApplicationPrivileges(Collections.singleton("foo"))
},
new ConfigurableClusterPrivileges.ManageApplicationPrivileges(Collections.singleton("foo")) },
null,
null,
null,
Expand All @@ -1427,7 +1427,8 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
new String[] { "foo" },
Expand All @@ -1446,7 +1447,8 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
Expand All @@ -1459,32 +1461,33 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
).hasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster(),
is(true)
);
//remote indices privileges are not allowed
// remote indices privileges are not allowed
assertThat(
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
null,
null,
new RoleDescriptor.RemoteIndicesPrivileges[] {
RoleDescriptor.RemoteIndicesPrivileges.builder("rmt").indices("idx").privileges("foo").build()
},
RoleDescriptor.RemoteIndicesPrivileges.builder("rmt").indices("idx").privileges("foo").build() },
null,
null,
null
).hasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster(),
is(true)
);
//remote cluster privileges are not allowed
// remote cluster privileges are not allowed
assertThat(
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
Expand All @@ -1494,7 +1497,7 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RemoteClusterPermissions().addGroup(
new RemoteClusterPermissionGroup(
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new String[]{"rmt"}
new String[] { "rmt" }
)
),
null,
Expand All @@ -1508,7 +1511,8 @@ public void testHasUnsupportedPrivilegesInsideAPIKeyConnectedRemoteCluster() {
new RoleDescriptor(
"name",
RemoteClusterPermissions.getSupportedRemoteClusterPermissions().toArray(new String[0]),
new RoleDescriptor.IndicesPrivileges[]{RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build()},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("idx").privileges("foo").build() },
null,
null,
null,
Expand Down

0 comments on commit 626b881

Please sign in to comment.