Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed use of rolesMappingConfiguration in InternalUsersApiActionValidationTest #4744

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading