Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

75525: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (5.0/Cloud)
      75287: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.3)
         75284: Merged V4.1.8 (4.1.8.11) to V4.1-BUG-FIX (4.1.10)
            75265: MNT-11766 : User with username starting with admin gets admin rights
               - Previous fix was corrected according to Derek's review.
               - Unit test that demonstrates fix added.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77485 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-07-22 12:55:23 +00:00
parent 27e2d25a8b
commit 8db8094c57
2 changed files with 30 additions and 17 deletions

View File

@@ -1420,6 +1420,30 @@ public class AuthorityServiceTest extends TestCase
assertEquals("Count of groups must increment", (groupCountBefore+1), groupCountAfter);
}
public void testMNT_11766()
{
Set<String> admins = authenticationComponent.getDefaultAdministratorUserNames();
for (String admin : admins)
{
// create user with MT format name (i.e. username@domain)
String user = admin + "@" + System.currentTimeMillis();
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4, 1.0f);
props.put(ContentModel.PROP_USERNAME, user);
props.put(ContentModel.PROP_FIRSTNAME, user);
props.put(ContentModel.PROP_LASTNAME, user);
props.put(ContentModel.PROP_EMAIL, user + "@gmail.com");
personService.createPerson(props);
authenticationService.createAuthentication(user, "123123".toCharArray());
authenticationComponent.setCurrentUser(user);
assertFalse("User should not have administrator role.", authorityService.hasAdminAuthority());
assertFalse("User should not have administrator role.", pubAuthorityService.hasAdminAuthority());
}
}
private void assertContains(List<String> results, List<String> checklist, boolean included)
{
for (String check : checklist)