mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1752, REPO-1753: Create person with an id that contains "/" does not return an error
- Added username validation on create person. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@134040 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -511,6 +511,7 @@ public class PeopleImpl implements People
|
||||
|
||||
private void validateCreatePersonData(Person person)
|
||||
{
|
||||
validateUsername(person.getUserName());
|
||||
validateNamespaces(person.getAspectNames(), person.getProperties());
|
||||
checkRequiredField("id", person.getUserName());
|
||||
checkRequiredField("firstName", person.getFirstName());
|
||||
@@ -518,6 +519,19 @@ public class PeopleImpl implements People
|
||||
checkRequiredField("password", person.getPassword());
|
||||
}
|
||||
|
||||
private void validateUsername(String username)
|
||||
{
|
||||
if (username.length() > 100)
|
||||
{
|
||||
throw new InvalidArgumentException("Username is too long.");
|
||||
}
|
||||
|
||||
if (username.indexOf('/') != -1)
|
||||
{
|
||||
throw new IllegalArgumentException("Username contains characters that are not permitted.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateNamespaces(List<String> aspectNames, Map<String, Object> properties)
|
||||
{
|
||||
if (aspectNames != null)
|
||||
|
@@ -289,6 +289,16 @@ public class TestPeople extends EnterpriseTestApi
|
||||
assertEquals("userStatus", p.getUserStatus());
|
||||
assertEquals(true, p.isEnabled());
|
||||
assertEquals(true, p.isEmailNotificationsEnabled());
|
||||
|
||||
// -ve tests
|
||||
// create person with username too long
|
||||
person.setUserName("myUserName11111111111111111111111111111111111111111111111111111111111111111111111111111111@" + account1.getId());
|
||||
people.create(person, 400);
|
||||
|
||||
// create person with special character '/'
|
||||
person.setUserName("myUser/Name@" + account1.getId());
|
||||
people.create(person, 400);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user