diff --git a/server-spi/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/server-spi/src/main/java/org/keycloak/models/utils/RepresentationToModel.java index b972cda3bf..c2e654efac 100755 --- a/server-spi/src/main/java/org/keycloak/models/utils/RepresentationToModel.java +++ b/server-spi/src/main/java/org/keycloak/models/utils/RepresentationToModel.java @@ -1746,6 +1746,10 @@ public class RepresentationToModel { } public static void updateComponent(KeycloakSession session, ComponentRepresentation rep, ComponentModel component, boolean internal) { + if (rep.getName() != null) { + component.setName(rep.getName()); + } + if (rep.getParentId() != null) { component.setParentId(rep.getParentId()); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java index 409a3e1e6f..d5a98f660c 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java @@ -144,6 +144,24 @@ public class ComponentsTest extends AbstractAdminTest { assertEquals(1, returned.getConfig().size()); } + + @Test + public void testRename() { + ComponentRepresentation rep = createComponentRepresentation("mycomponent"); + rep.getConfig().addFirst("required", "foo"); + + String id = createComponent(rep); + ComponentRepresentation returned = components.component(id).toRepresentation(); + assertEquals("mycomponent", returned.getName()); + + rep.setName("myupdatedcomponent"); + + components.component(id).update(rep); + + returned = components.component(id).toRepresentation(); + assertEquals("myupdatedcomponent", returned.getName()); + } + @Test public void testSecretConfig() throws Exception { ComponentRepresentation rep = createComponentRepresentation("mycomponent");