Skip to content

Commit

Permalink
Fixed use of rolesMappingConfiguration in InternalUsersApiActionValid…
Browse files Browse the repository at this point in the history
…ationTest (#4744)

Signed-off-by: Nils Bandener <[email protected]>
  • Loading branch information
nibix authored Sep 24, 2024
1 parent e7a79a8 commit a62e99a
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void setupRolesAndMappings() throws IOException {
allClusterPermissions.setCluster_permissions(List.of("*"));
@SuppressWarnings("unchecked")
final var c = (SecurityDynamicConfiguration<RoleV7>) rolesConfiguration;
c.putCEntry("some_role_with_static_mapping", allClusterPermissions);
c.putCEntry("some_role_with_reserved_mapping", allClusterPermissions);
c.putCEntry("some_role_with_hidden_mapping", allClusterPermissions);

Expand All @@ -72,13 +71,12 @@ public void setupRolesAndMappings() throws IOException {
config.set("all_access", objectMapper.createObjectNode());
config.set("regular_role", objectMapper.createObjectNode());

config.set("some_role_with_static_mapping", objectMapper.createObjectNode().put("static", true));
config.set("some_role_with_reserved_mapping", objectMapper.createObjectNode().put("reserved", true));
config.set("some_role_with_hidden_mapping", objectMapper.createObjectNode().put("hidden", true));

final var rolesMappingConfiguration = SecurityDynamicConfiguration.fromJson(
objectMapper.writeValueAsString(config),
CType.ROLES,
CType.ROLESMAPPING,
2,
1,
1
Expand Down Expand Up @@ -187,11 +185,6 @@ public void validateSecurityRolesWithImmutableRolesMappingConfig() throws Except
.set("opendistro_security_roles", objectMapper.createArrayNode().add("some_role_with_reserved_mapping"));
result = internalUsersApiAction.validateSecurityRoles(SecurityConfiguration.of(userJson, "some_user", configuration));
assertFalse(result.isValid());
// should not be ok to set role with static role mapping
userJson = objectMapper.createObjectNode()
.set("opendistro_security_roles", objectMapper.createArrayNode().add("some_role_with_static_mapping"));
result = internalUsersApiAction.validateSecurityRoles(SecurityConfiguration.of(userJson, "some_user", configuration));
assertFalse(result.isValid());
}

private InternalUsersApiAction createInternalUsersApiAction() {
Expand Down

0 comments on commit a62e99a

Please sign in to comment.