8000 Preserve organization group descriptions when importing a realm by Praiztl · Pull Request #55600 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Draft
Show file tree
Hide file tree
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 @@ -1867,6 +1867,10 @@ private void validateClientAndRealmTimeouts(RealmModel realm) {
private void importOrganizationGroup(OrganizationProvider provider, OrganizationModel organization, RealmModel realm, GroupRepresentation groupRep, GroupModel parent) {
GroupModel group = provider.createGroup(organization, groupRep.getId(), groupRep.getName(), parent);

if (groupRep.getDescription() != null) {
group.setDescription(groupRep.getDescription());
}

if (groupRep.getAttributes() != null) {
for (Map.Entry<String, List<String>> attr : groupRep.getAttributes().entrySet()) {
group.setAttribute(attr.getKey(), attr.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ private void validateOrganizationGroups(OrganizationResource organization, Map<S
assertThat(topLevelGroupNames, hasItem(Matchers.startsWith("Department-")));
assertThat(topLevelGroupNames, hasItem(Matchers.startsWith("Team-")));

// Validate top-level group descriptions are preserved (issue 55134)
topLevelGroups.forEach(group ->
assertThat(group.getDescription(), equalTo("Description of " + group.getName())));

// Validate group IDs are preserved
validateGroupIds(topLevelGroups, expectedGroupIds);

Expand Down Expand Up @@ -475,6 +479,7 @@ private void assertPartialExportImport(HttpClient client, OrganizationRepresenta
assertThat(exportedLink.getMembershipType(), equalTo(expectedLink.getMembershipType()));

assertThat(exported.getGroups().stream().map(GroupRepresentation::getName).toList(), containsInAnyOrder("Department"));
assertThat(exported.getGroups().get(0).getDescription(), equalTo("Description of Department"));
assertThat(Optional.ofNullable(exported.getMembers()).orElse(List.of()), empty());
assertTrue(Optional.ofNullable(export.getIdentityProviders()).orElse(List.of()).stream().noneMatch(idp -> idp.getOrganizationLinks() != null && !idp.getOrganizationLinks().isEmpty()));

Expand All @@ -487,6 +492,7 @@ private void assertPartialExportImport(HttpClient client, OrganizationRepresenta
private String createTopLevelGroup(OrganizationResource organization, String name) {
GroupRepresentation group = new GroupRepresentation();
group.setName(name);
group.setDescription("Description of " + name);
try (Response response = organization.groups().addTopLevelGroup(group)) {
assertThat(response.getStatus(), equalTo(Response.Status.CREATED.getStatusCode()));
return ApiUtil.getCreatedId(response);
Expand Down
0