Bugfix for: Removing all group attributes no longer works with keycloak-admin-client (java)

Closes #25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
This commit is contained in:
Daniel Fesenmeyer 2023-12-19 10:22:26 +01:00 committed by Marek Posolda
parent cf57af1d10
commit baafb670f7
2 changed files with 25 additions and 2 deletions

View file

@ -17,7 +17,6 @@
package org.keycloak.representations.idm;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -30,7 +29,6 @@ import java.util.stream.Collectors;
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class GroupRepresentation {
// For an individual group these are the sufficient minimum fields
// to identify a group and operate on it in a basic way

View file

@ -1250,6 +1250,31 @@ public class GroupTest extends AbstractGroupTest {
}
}
@Test
public void removeAllGroupAttributes() {
final var realm = adminClient.realms().realm("test");
final var groupName = "remove-all-attributes-group";
final Map<String, List<String>> initialAttributes = Map.of("test-key", List.of("test-val"));
final var groupToCreate =
GroupBuilder.create().name(groupName).attributes(initialAttributes).build();
final var groupsResource = realm.groups();
try (final Response response = groupsResource.add(groupToCreate)) {
final var groupId = ApiUtil.getCreatedId(response);
final var groupResource = groupsResource.group(groupId);
final var createdGroup = groupResource.toRepresentation();
assertThat(createdGroup.getAttributes(), equalTo(initialAttributes));
final var groupToUpdate =
GroupBuilder.create().name(groupName).attributes(Collections.emptyMap()).build();
groupResource.update(groupToUpdate);
final var updatedGroup = groupResource.toRepresentation();
assertThat(updatedGroup.getAttributes(), anEmptyMap());
}
}
@Test
public void testBriefRepresentationOnGroupMembers() {
RealmResource realm = adminClient.realms().realm("test");