mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
58165: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 58031: Reverse merged (again) in V4.2-BUG-FIX - merged the wrong commit 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@61930 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
5bf400fac6
commit
d447b6b36a
@ -606,13 +606,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
|
||||
{
|
||||
checkTypeIsMutable(type);
|
||||
String name = getName(type, shortName);
|
||||
|
||||
//MNT-9794 fix. If authority with 'name' doesn't exist it will be created
|
||||
if (!authorityDAO.authorityExists(name))
|
||||
{
|
||||
authorityDAO.createAuthority(name, authorityDisplayName, authorityZones);
|
||||
}
|
||||
|
||||
authorityDAO.createAuthority(name, authorityDisplayName, authorityZones);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -591,34 +591,6 @@ 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user