Merged V2.2 to HEAD (re-merge of r11057)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11236 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-10-07 13:18:54 +00:00
parent 1a65e7d914
commit d2748b308f

View File

@@ -86,8 +86,34 @@ public class AuthorityServiceTest extends TestCase
authenticationComponentImpl.setSystemUserAsCurrentUser();
TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE
.getLocalName());
TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
tx = transactionService.getUserTransaction();
tx.begin();
for (String user : pubAuthorityService.getAllAuthorities(AuthorityType.USER))
{
if (user.equals("guest"))
{
continue;
}
else if (user.equals("admin"))
{
continue;
}
else
{
if (personService.personExists(user))
{
personService.deletePerson(user);
}
if (authenticationDAO.userExists(user))
{
authenticationDAO.deleteUser(user);
}
}
}
tx.commit();
tx = transactionService.getUserTransaction();
tx.begin();
@@ -140,21 +166,17 @@ public class AuthorityServiceTest extends TestCase
public void testAuthorities()
{
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).size());
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).contains(
PermissionService.ADMINISTRATOR_AUTHORITY));
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).contains(PermissionService.ADMINISTRATOR_AUTHORITY));
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.EVERYONE).size());
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.EVERYONE).contains(
PermissionService.ALL_AUTHORITIES));
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.EVERYONE).contains(PermissionService.ALL_AUTHORITIES));
// group added for email
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
assertFalse(pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).contains(
PermissionService.ALL_AUTHORITIES));
assertFalse(pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).contains(PermissionService.ALL_AUTHORITIES));
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GUEST).size());
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.GUEST).contains(PermissionService.GUEST_AUTHORITY));
assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.OWNER).size());
assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.ROLE).size());
assertEquals(personService.getAllPeople().size(), pubAuthorityService.getAllAuthorities(AuthorityType.USER)
.size());
assertEquals(personService.getAllPeople().size(), pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
}
@@ -522,7 +544,6 @@ public class AuthorityServiceTest extends TestCase
assertTrue(pubAuthorityService.getContainedAuthorities(null, auth1, false).contains(auth4));
assertTrue(pubAuthorityService.getContainedAuthorities(null, auth1, false).contains("andy"));
pubAuthorityService.addAuthority(auth3, auth2);
assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
@@ -547,7 +568,6 @@ public class AuthorityServiceTest extends TestCase
}
public void test_AR_1510()
{
personService.getPerson("andy1");
@@ -669,7 +689,6 @@ public class AuthorityServiceTest extends TestCase
assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth6, true).size());
assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth6, false).size());
assertEquals(5, pubAuthorityService.getContainingAuthorities(null, "andy1", true).size());
assertEquals(6, pubAuthorityService.getContainingAuthorities(null, "andy1", false).size());
assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy2", true).size());
@@ -710,11 +729,8 @@ public class AuthorityServiceTest extends TestCase
assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy6", false).size());
}
/**
* Test toknisation of group members
*
*/
public void test_AR_1517__AND__AR_1411()
{
@@ -733,7 +749,6 @@ public class AuthorityServiceTest extends TestCase
personService.getPerson("an3dy");
assertTrue(personService.personExists("an3dy"));
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
assertEquals(1, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
String auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
@@ -749,7 +764,6 @@ public class AuthorityServiceTest extends TestCase
String auth6 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "six");
pubAuthorityService.addAuthority(auth6, "an3dy");
assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth1, true).size());
assertTrue(pubAuthorityService.getContainedAuthorities(null, auth1, true).contains("1234"));
assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth2, true).size());
@@ -778,7 +792,6 @@ public class AuthorityServiceTest extends TestCase
}
public void testGroupNameTokenisation()
{
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
@@ -815,8 +828,7 @@ public class AuthorityServiceTest extends TestCase
assertEquals(1, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
}
private Map<QName, Serializable> createDefaultProperties(String userName, String firstName, String lastName,
String email, String orgId, NodeRef home)
private Map<QName, Serializable> createDefaultProperties(String userName, String firstName, String lastName, String email, String orgId, NodeRef home)
{
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_USERNAME, userName);