diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java index 6cec9f63ba..8e65321208 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java @@ -113,7 +113,9 @@ public class UserAttributesForm extends Form { public void setValues(UserRepresentation user) { waitUntilElement(usernameInput).is().present(); - setUsername(user.getUsername()); + if (user.getUsername() != null) { + setUsername(user.getUsername()); + } setEmail(user.getEmail()); setFirstName(user.getFirstName()); setLastName(user.getLastName()); diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/users/UserAttributesTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/users/UserAttributesTest.java index 03428ae283..d228527e3f 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/users/UserAttributesTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/users/UserAttributesTest.java @@ -20,6 +20,7 @@ package org.keycloak.testsuite.console.users; import org.jboss.arquillian.graphene.page.Page; import org.junit.Before; import org.junit.Test; +import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.testsuite.console.page.users.UserAttributes; @@ -55,6 +56,17 @@ public class UserAttributesTest extends AbstractUserTest { assertNull(usersPage.table().findUser(testUsername)); } + @Test + public void createUserEmailAsUserName() { + RealmRepresentation representation = testRealmResource().toRepresentation(); + representation.setRegistrationEmailAsUsername(true); + testRealmResource().update(representation); + + newTestRealmUser.setEmail("test@keycloak.org"); + createUser(newTestRealmUser); + assertAlertSuccess(); + } + @Test public void noUsername() { createUser(newTestRealmUser); diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/user-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/user-detail.html index b985a52af3..df66351b26 100755 --- a/themes/src/main/resources/theme/base/admin/resources/partials/user-detail.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/user-detail.html @@ -29,7 +29,7 @@
+ data-ng-required="!emailAsUsername" ng-pattern="/^[^\<\>\\\/]*$/" data-ng-readonly="!editUsername">