From 46d3555798c550521b9faee845043e9bfe000a1c Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Mon, 28 Nov 2016 12:30:08 +0100 Subject: [PATCH] KEYCLOAK-3439, KEYCLOAK-3893, KEYCLOAK-3894 - Support for Unicode Treatment of Unicode characters varies among databases. This change adds support for Unicode characters in the following fields: * Realms: display name, HTML display name * Users: username, given name, last name, attribute values * Groups: name, attribute values * Components: attribute values * Roles: name * Descriptions of objects Unicode support for the rest of the fields depends on database vendor and is described in the installation guide in more detail. --- .../META-INF/jpa-changelog-2.4.1.xml | 75 +++++++++++++++++++ .../testsuite/admin/ComponentsTest.java | 29 +++++++ 2 files changed, 104 insertions(+) diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml index 216ce651c8..8c14b67db6 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-2.4.1.xml @@ -22,4 +22,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE COMPONENT_CONFIG SET VALUE_NEW = VALUE, VALUE = NULL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 d5a98f660c..6902dacce3 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 @@ -31,6 +31,7 @@ import javax.ws.rs.core.Response; import java.util.Collections; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import static org.junit.Assert.*; @@ -210,6 +211,34 @@ public class ComponentsTest extends AbstractAdminTest { assertEquals(ComponentRepresentation.SECRET_VALUE, returned3.getConfig().getFirst("secret")); } + @Test + public void testLongValueInComponentConfigAscii() throws Exception { + ComponentRepresentation rep = createComponentRepresentation("mycomponent"); + String value = StringUtils.repeat("0123456789", 400); // 4000 8-bit characters + + rep.getConfig().addFirst("required", "foo"); + rep.getConfig().addFirst("val1", value); + + String id = createComponent(rep); + + ComponentRepresentation returned = components.component(id).toRepresentation(); + assertEquals(value, returned.getConfig().getFirst("val1")); + } + + @Test + public void testLongValueInComponentConfigExtLatin() throws Exception { + ComponentRepresentation rep = createComponentRepresentation("mycomponent"); + String value = StringUtils.repeat("ěščřžýíŮÍÁ", 400); // 4000 Unicode extended-Latin characters + + rep.getConfig().addFirst("required", "foo"); + rep.getConfig().addFirst("val1", value); + + String id = createComponent(rep); + + ComponentRepresentation returned = components.component(id).toRepresentation(); + assertEquals(value, returned.getConfig().getFirst("val1")); + } + private String createComponent(ComponentRepresentation rep) { ComponentsResource components = realm.components(); Response response = components.add(rep);