mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
58164: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 58030: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1) 56942: Merged DEV to V4.1-BUG-FIX (4.1.7) 56883 : MNT-9794: Authorities with duplicate names can be easilly created using « AuthorityService » - Creation of the duplicated authorities is fixed. Unit tests are added. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61929 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -591,6 +591,34 @@ public class AuthorityServiceTest extends TestCase
|
||||
pubAuthorityService.deleteAuthority(auth1);
|
||||
assertEquals(0, getAllAuthorities(AuthorityType.ROLE).size());
|
||||
assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.ROLE).size());
|
||||
|
||||
// Testing MNT-9794 fix. Creates authority 'DUPLICATEDGROUP' twice. Only one authority with such name should be created.
|
||||
String dublicatedAuthorityShortName = "DUPLICATEDGROUP";
|
||||
AuthorityType dublicatedAuthorityType = AuthorityType.GROUP;
|
||||
|
||||
//Creates authority twice with duplicated name
|
||||
pubAuthorityService.createAuthority(dublicatedAuthorityType, dublicatedAuthorityShortName);
|
||||
pubAuthorityService.createAuthority(dublicatedAuthorityType, dublicatedAuthorityShortName);
|
||||
|
||||
List<String> duplicatedGroupAuthorities = getAuthorityByTypeAndShortName(dublicatedAuthorityType, dublicatedAuthorityShortName);
|
||||
|
||||
//Only one authority should be created with duplicated name
|
||||
assertEquals(1, duplicatedGroupAuthorities.size());
|
||||
|
||||
pubAuthorityService.deleteAuthority("GROUP_DUPLICATEDGROUP");
|
||||
List<String> duplicatedAuthoritiesAfterDelete = getAuthorityByTypeAndShortName(dublicatedAuthorityType, dublicatedAuthorityShortName);
|
||||
assertEquals(0, duplicatedAuthoritiesAfterDelete.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of authorities according the authority type and authority short name
|
||||
* @param type authority type
|
||||
* @param shortName authority short name
|
||||
* @return List of String authorities
|
||||
*/
|
||||
private List<String> getAuthorityByTypeAndShortName(AuthorityType type, String shortName)
|
||||
{
|
||||
return pubAuthorityService.getAuthorities(type, null, shortName, false, true, new PagingRequest(0, Integer.MAX_VALUE, null)).getPage();
|
||||
}
|
||||
|
||||
private void checkAuthorityCollectionSize(int expected, List<String> actual, AuthorityType type)
|
||||
|
Reference in New Issue
Block a user