RM-1224 (Rmadmin user is not created if auth chain contains not only ALfrescoNTLM)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@73546 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-06-11 08:53:23 +00:00
parent 249c03c345
commit a2400a047c
27 changed files with 225 additions and 733 deletions

View File

@@ -95,7 +95,7 @@ public class FileToActionTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
private void initRecord()
@@ -147,7 +147,7 @@ public class FileToActionTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
public void testFileToPath2()
@@ -175,7 +175,7 @@ public class FileToActionTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
public void testCreate() throws Exception
@@ -237,7 +237,7 @@ public class FileToActionTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
public void failureTests() throws Exception

View File

@@ -60,7 +60,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
private NodeRef moveToFolder;
private NodeRef moveToCategory;
private NodeRef hold;
@Override
@@ -109,9 +109,9 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
utils.declareRecord(declaredRecord);
utils.declareRecord(frozenRecord);
utils.declareRecord(frozenRecord2);
hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description");
holdService.addToHold(hold, frozenRecord);
holdService.addToHold(hold, frozenRecordFolder);
holdService.addToHold(hold, frozenRecord2);
@@ -349,7 +349,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
}
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -445,7 +445,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
}
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{

View File

@@ -92,7 +92,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -130,7 +130,7 @@ public class RM1008Test extends BaseRMTestCase
holdService.addToHold(hold, rmFolder);
return hold;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -145,7 +145,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -171,7 +171,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -197,7 +197,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -282,7 +282,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -308,7 +308,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -334,7 +334,7 @@ public class RM1008Test extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{

View File

@@ -26,30 +26,30 @@ import org.alfresco.service.cmr.site.SiteRole;
/**
* Unit test for RM-804 .. site managers are able to delete file plans
*
*
* @author Roy Wetherall
* @since 2.1
*/
public class RM804Test extends BaseRMTestCase
{
public class RM804Test extends BaseRMTestCase
{
@Override
protected void initServices()
{
super.initServices();
}
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
@Override
protected boolean isUserTest()
{
return true;
}
public void testUsersHaveDeletePermissionsOnFilePlan() throws Exception
{
// as rmuser
@@ -59,32 +59,32 @@ public class RM804Test extends BaseRMTestCase
public Void run()
{
assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete"));
return null;
}
}, "rmadmin");
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete"));
return null;
}
}, "admin");
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
assertEquals(AccessStatus.ALLOWED, capabilityService.getCapabilityAccessState(filePlan, "Delete"));
return null;
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new Test<Void>()
{
@@ -92,23 +92,23 @@ public class RM804Test extends BaseRMTestCase
public Void run()
{
assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete"));
return null;
}
}, rmUserName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
assertEquals(AccessStatus.DENIED, capabilityService.getCapabilityAccessState(filePlan, "Delete"));
return null;
}
}, userName);
}
public void testTryAndDeleteSiteAsSiteManagerOnly()
{
doTestInTransaction(new Test<Void>()
@@ -117,25 +117,25 @@ public class RM804Test extends BaseRMTestCase
public Void run()
{
siteService.setMembership(siteId, userName, SiteRole.SiteManager.toString());
return null;
}
}, "admin");
doTestInTransaction(new FailureTest
(
"Should not be able to delete site as a site manager only.",
AlfrescoRuntimeException.class
)
{
{
@Override
public void run() throws Exception
{
siteService.deleteSite(siteId);
}
}, userName);
// give the user a RM role (but not sufficient to delete the file plan node ref)
doTestInTransaction(new Test<Void>()
{
@@ -143,47 +143,47 @@ public class RM804Test extends BaseRMTestCase
public Void run()
{
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_USER, userName);
return null;
}
}, "admin");
doTestInTransaction(new FailureTest
(
"Should not be able to delete site as a site manager with an RM role that doesn't have the capability.",
AlfrescoRuntimeException.class
)
{
{
@Override
public void run() throws Exception
{
siteService.deleteSite(siteId);
}
}, userName);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_ADMINISTRATOR, userName);
return null;
}
}, "admin");
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
siteService.deleteSite(siteId);
return null;
}
}, userName);
}
}

View File

@@ -117,7 +117,7 @@ public class CustomEMailMappingServiceImplTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
private CustomMapping getCustomMapping(String from, String to)

View File

@@ -29,7 +29,7 @@ import org.alfresco.service.namespace.QName;
/**
* Model security service test.
*
*
* @author Roy Wetherall
* @since 2.1
*/
@@ -37,16 +37,16 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
{
private static final QName CUSTOM_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customAspect");
private static final QName CUSTOM_PROTECTED_ASPECT = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedAspect");
private static final QName CUSTOM_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProperty");
private static final QName CUSTOM_PROTECTED_PROPERTY = QName.createQName("http://www.alfresco.org/model/rmtest/1.0", "customProtectedProperty");
/** Model security service */
private ModelSecurityService modelSecurityService;
private ModelSecurityService modelSecurityService;
private boolean enabled;
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest()
*/
@@ -55,23 +55,23 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
{
return true;
}
@Override
protected boolean isFillingForAllUsers()
{
return true;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
*/
@Override
protected void initServices()
{
super.initServices();
super.initServices();
modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService");
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestDataImpl()
*/
@@ -79,11 +79,11 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
protected void setupTestDataImpl()
{
super.setupTestDataImpl();
enabled = modelSecurityService.isEnabled();
modelSecurityService.setEnabled(true);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDownImpl()
*/
@@ -93,77 +93,77 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
super.tearDownImpl();
modelSecurityService.setEnabled(enabled);
}
/**
* test - getProtectedAspects(), isProtectedAspect(), getProtectedAspect()
*/
public void testProtectedAspects() throws Exception
{
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
Set<QName> protectedAspects = modelSecurityService.getProtectedAspects();
assertNotNull(protectedAspects);
assertFalse(protectedAspects.isEmpty());
assertTrue(protectedAspects.contains(CUSTOM_PROTECTED_ASPECT));
assertFalse(protectedAspects.contains(CUSTOM_ASPECT));
assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT));
assertFalse(modelSecurityService.isProtectedAspect(CUSTOM_ASPECT));
ProtectedAspect protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_ASPECT);
assertNull(protectedAspect);
protectedAspect = modelSecurityService.getProtectedAspect(CUSTOM_PROTECTED_ASPECT);
assertNotNull(protectedAspect);
assertNotNull(protectedAspect.getQName());
assertNotNull(protectedAspect.getCapabilities());
assertNotNull(protectedAspect.getCapabilities());
}
});
});
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertTrue(modelSecurityService.isProtectedAspect(CUSTOM_PROTECTED_ASPECT));
assertFalse(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT));
assertFalse(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT));
}
}, powerUserName);
doTestInTransaction(new FailureTest
(
"Normal rm user should not have the permissions to add the protected aspect.",
"Normal rm user should not have the permissions to add the protected aspect.",
ModelAccessDeniedException.class
)
{
@Override
public void run() throws Exception
{
// try and add the aspect
// try and add the aspect
nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null);
}
}
}, powerUserName);
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertTrue(modelSecurityService.canEditProtectedAspect(rmFolder, CUSTOM_PROTECTED_ASPECT));
// try and add the aspect
nodeService.addAspect(rmFolder, CUSTOM_PROTECTED_ASPECT, null);
assertTrue(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT));
}
}, rmAdminName);
}, ADMIN_USER);
// check protected aspect via removeAspect
doTestInTransaction(new FailureTest
(
"Normal rm user should not have the permissions to remove the custom aspect.",
"Normal rm user should not have the permissions to remove the custom aspect.",
ModelAccessDeniedException.class
)
{
@@ -171,20 +171,20 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
public void run() throws Exception
{
nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT);
}
}
}, powerUserName);
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
nodeService.removeAspect(rmFolder, CUSTOM_PROTECTED_ASPECT);
assertFalse(nodeService.hasAspect(rmFolder, CUSTOM_PROTECTED_ASPECT));
}
}, rmAdminName);
}, ADMIN_USER);
}
/**
* test - getProtectedProperties(), isProtectedProperty(), getProtectedProperty()
*/
@@ -195,55 +195,55 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
public void runImpl()
{
Set<QName> protectedProperties = modelSecurityService.getProtectedProperties();
assertNotNull(protectedProperties);
assertFalse(protectedProperties.isEmpty());
assertTrue(protectedProperties.contains(CUSTOM_PROTECTED_PROPERTY));
assertFalse(protectedProperties.contains(CUSTOM_PROPERTY));
assertFalse(protectedProperties.contains(CUSTOM_PROPERTY));
assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY));
assertFalse(modelSecurityService.isProtectedProperty(CUSTOM_PROPERTY));
ProtectedProperty protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROPERTY);
assertNull(protectedProperty);
protectedProperty = modelSecurityService.getProtectedProperty(CUSTOM_PROTECTED_PROPERTY);
assertNotNull(protectedProperty);
assertNotNull(protectedProperty.getQName());
assertNotNull(protectedProperty.getCapabilities());
assertNotNull(protectedProperty.getCapabilities());
}
});
});
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
}
}, rmAdminName);
}, ADMIN_USER);
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
}
}, powerUserName);
}, powerUserName);
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertTrue(modelSecurityService.isProtectedProperty(CUSTOM_PROTECTED_PROPERTY));
assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
assertFalse(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
}
}, powerUserName);
doTestInTransaction(new FailureTest
(
"Should not have the permissions to edit protected property.",
"Should not have the permissions to edit protected property.",
ModelAccessDeniedException.class
)
{
@@ -251,19 +251,19 @@ public class ModelSecurityServiceImplTest extends BaseRMTestCase
public void run() throws Exception
{
nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello");
}
}
}, powerUserName);
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
assertTrue(modelSecurityService.canEditProtectedProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
nodeService.setProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY, "hello");
assertEquals("hello", nodeService.getProperty(rmFolder, CUSTOM_PROTECTED_PROPERTY));
}
}, rmAdminName);
}, ADMIN_USER);
}
}

View File

@@ -501,7 +501,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
public void testFileNewContent() throws Exception
@@ -643,7 +643,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
}
});
// test rmadmin
// test admin
doTestInTransaction(new VoidTest()
{
@Override
@@ -738,11 +738,11 @@ public class RecordServiceImplTest extends BaseRMTestCase
}
});
// test rmadmin
canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, rmAdminName);
canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, rmAdminName);
cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, rmAdminName);
canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, rmAdminName);
// test admin
canEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER);
canEditProperty(recordOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER);
cantEditProperty(recordDeclaredOne, ContentModel.PROP_DESCRIPTION, ADMIN_USER);
canEditProperty(recordDeclaredOne, RecordsManagementModel.PROP_LOCATION, ADMIN_USER);
// test normal user
cantEditProperty(recordOne, ContentModel.PROP_DESCRIPTION, rmUserName);

View File

@@ -138,7 +138,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
}
/**
@@ -147,13 +147,13 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
public void testGetAuditTrail()
{
// show the audit is empty
getAuditTrail(1, rmAdminName);
getAuditTrail(1, ADMIN_USER);
// make a change
final String updatedProperty = updateTitle(filePlan, rmAdminName);
final String updatedProperty = updateTitle(filePlan, ADMIN_USER);
// show the audit has been updated
List<RecordsManagementAuditEntry> entries = getAuditTrail(3, rmAdminName);
List<RecordsManagementAuditEntry> entries = getAuditTrail(3, ADMIN_USER);
final RecordsManagementAuditEntry entry = entries.get(2);
assertNotNull(entry);
@@ -182,15 +182,15 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
return null;
}
}, rmAdminName);
}, ADMIN_USER);
// add some more title updates
updateTitle(rmContainer, rmAdminName);
updateTitle(rmFolder, rmAdminName);
updateTitle(record, rmAdminName);
updateTitle(rmContainer, ADMIN_USER);
updateTitle(rmFolder, ADMIN_USER);
updateTitle(record, ADMIN_USER);
// show the audit has been updated
getAuditTrail(7, rmAdminName);
getAuditTrail(7, ADMIN_USER);
// snap shot date
Date snapShot = new Date();
@@ -198,7 +198,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
// show the audit results can be limited
RecordsManagementAuditQueryParameters params = new RecordsManagementAuditQueryParameters();
params.setMaxEntries(2);
getAuditTrail(params, 2, rmAdminName);
getAuditTrail(params, 2, ADMIN_USER);
// test filter by user
updateTitle(rmContainer, recordsManagerName);
@@ -207,39 +207,39 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
params = new RecordsManagementAuditQueryParameters();
params.setUser(recordsManagerName);
getAuditTrail(params, 3, rmAdminName);
getAuditTrail(params, 3, ADMIN_USER);
// test filter by date
params = new RecordsManagementAuditQueryParameters();
params.setDateFrom(snapShot);
getAuditTrail(params, 13, rmAdminName);
getAuditTrail(params, 13, ADMIN_USER);
params = new RecordsManagementAuditQueryParameters();
params.setDateTo(snapShot);
getAuditTrail(params, 14, rmAdminName);
getAuditTrail(params, 14, ADMIN_USER);
params.setDateFrom(testStartTime);
getAuditTrail(params, 15, rmAdminName);
getAuditTrail(params, 15, ADMIN_USER);
// test filter by object
updateTitle(record, rmAdminName);
updateTitle(record, rmAdminName);
updateTitle(record, rmAdminName);
updateTitle(record, ADMIN_USER);
updateTitle(record, ADMIN_USER);
updateTitle(record, ADMIN_USER);
params = new RecordsManagementAuditQueryParameters();
params.setNodeRef(record);
getAuditTrail(params, 5, rmAdminName);
getAuditTrail(params, 5, ADMIN_USER);
// test filter by event
params = new RecordsManagementAuditQueryParameters();
// params.setEvent("cutoff");
// getAuditTrail(params, 0, rmAdminName);
// getAuditTrail(params, 0, ADMIN_USER);
params.setEvent("Update RM Object");
getAuditTrail(params, 10, rmAdminName);
getAuditTrail(params, 10, ADMIN_USER);
// test filter by property
// params = new RecordsManagementAuditQueryParameters();
//params.setProperty(PROP_ADDRESSEES);
//getAuditTrail(params, 0, rmAdminName);
//getAuditTrail(params, 0, ADMIN_USER);
// params.setProperty(PROP_TITLE);
// getAuditTrail(params, 10, rmAdminName);
// getAuditTrail(params, 10, ADMIN_USER);
}
/**
@@ -260,16 +260,16 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
Thread.sleep(5000);
List<RecordsManagementAuditEntry> result1 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result1 = getAuditTrail(ADMIN_USER);
assertNotNull(result1);
// Update the fileplan
updateTitle(filePlan, rmAdminName);
updateTitle(filePlan, ADMIN_USER);
Thread.sleep(5000);
// There should be no new audit entries
List<RecordsManagementAuditEntry> result2 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result2 = getAuditTrail(ADMIN_USER);
assertNotNull(result2);
assertEquals(
"Audit results should not have changed after auditing was disabled",
@@ -277,11 +277,11 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
// repeat with a start
rmAuditService.startAuditLog(filePlan);
updateTitle(filePlan, rmAdminName);
updateTitle(filePlan, ADMIN_USER);
Thread.sleep(5000);
List<RecordsManagementAuditEntry> result3 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result3 = getAuditTrail(ADMIN_USER);
assertNotNull(result3);
assertTrue(
"Expected more results after enabling audit",
@@ -294,7 +294,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
rmAuditService.clearAuditLog(filePlan);
// There should be no entries
List<RecordsManagementAuditEntry> result4 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result4 = getAuditTrail(ADMIN_USER);
assertNotNull(result4);
assertEquals(
"Audit entries should have been cleared",
@@ -342,7 +342,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
AuthenticationUtil.popAuthentication();
}
rmAuditService.stopAuditLog(filePlan);
List<RecordsManagementAuditEntry> result1 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result1 = getAuditTrail(ADMIN_USER);
// Check that the username is reflected correctly in the results
assertFalse("No audit results were generated for the failed login.", result1.isEmpty());
boolean found = false;
@@ -386,7 +386,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase
AuthenticationUtil.popAuthentication();
}
rmAuditService.stopAuditLog(filePlan);
List<RecordsManagementAuditEntry> result2 = getAuditTrail(rmAdminName);
List<RecordsManagementAuditEntry> result2 = getAuditTrail(ADMIN_USER);
found = false;
for (RecordsManagementAuditEntry entry : result2)
{

View File

@@ -45,7 +45,6 @@ import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.policy.BehaviourFilter;
@@ -104,12 +103,12 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected QName ASPECT_CUSTOM_ASPECT = QName.createQName(URI, "customAspect");
protected QName ASPECT_RECORD_META_DATA = QName.createQName(URI, "recordMetaData");
/** admin user */
protected static final String ADMIN_USER = "admin";
/** Common test utils */
protected CommonRMTestUtils utils;
/** RM Admin user name */
protected String rmAdminUserName;
/** Services */
protected NodeService nodeService;
protected ContentService contentService;
@@ -143,7 +142,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected FreezeService freezeService;
protected RecordService recordService;
protected FilePlanService filePlanService;
protected FilePlanAuthenticationService filePlanAuthenticationService;
protected RecordFolderService recordFolderService;
protected ExtendedSecurityService extendedSecurityService;
protected ReportService reportService;
@@ -224,7 +222,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected String powerUserName;
protected String securityOfficerName;
protected String recordsManagerName;
protected String rmAdminName;
/** test people */
protected NodeRef userPerson;
@@ -232,7 +229,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
protected NodeRef powerUserPerson;
protected NodeRef securityOfficerPerson;
protected NodeRef recordsManagerPerson;
protected NodeRef rmAdminPerson;
/** test records */
protected NodeRef recordOne;
@@ -320,20 +316,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
// Initialise the service beans
initServices();
// grab the rmadmin user name
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable
{
// As system user
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
rmAdminUserName = filePlanAuthenticationService.getRmAdminUserName();
return null;
}
});
// Setup test data
setupTestData();
@@ -394,7 +376,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
freezeService = (FreezeService) applicationContext.getBean("FreezeService");
recordService = (RecordService) applicationContext.getBean("RecordService");
filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService");
filePlanAuthenticationService = (FilePlanAuthenticationService) applicationContext.getBean("FilePlanAuthenticationService");
recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService");
extendedSecurityService = (ExtendedSecurityService) applicationContext.getBean("ExtendedSecurityService");
reportService = (ReportService) applicationContext.getBean("ReportService");
@@ -542,8 +523,8 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
containerProps).getChildRef();
assertNotNull("Could not create base folder", folder);
permissionService.setPermission(folder, "rmadmin", PermissionService.WRITE, true);
permissionService.setPermission(folder, "rmadmin", PermissionService.ADD_CHILDREN, true);
permissionService.setPermission(folder, ADMIN_USER, PermissionService.WRITE, true);
permissionService.setPermission(folder, ADMIN_USER, PermissionService.ADD_CHILDREN, true);
if (isRMSiteTest())
{
@@ -622,18 +603,13 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
recordsManagerPerson = createPerson(recordsManagerName);
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, recordsManagerName);
rmAdminName = GUID.generate();
rmAdminPerson = createPerson(rmAdminName);
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, rmAdminName);
testUsers = new String[]
{
userName,
rmUserName,
powerUserName,
securityOfficerName,
recordsManagerName,
rmAdminName
recordsManagerName
};
if (isFillingForAllUsers())
@@ -769,7 +745,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
}
/**
* Override to ensure the tests are run as the 'rmadmin' user by default.
* Override to ensure the tests are run as the 'admin' user by default.
*/
@Override
@@ -812,70 +788,70 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
// empty implementation
}
}
/**
* Execute behaviour driven test.
*
*
* @param test
*/
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
{
test.run();
}
/**
* Behaviour driven test.
*
*
* @author Roy Wetherall
* @since 2.2
*/
protected abstract class BehaviourDrivenTest
{
protected Class<?> expectedException;
public BehaviourDrivenTest()
{
}
public BehaviourDrivenTest(Class<?> expectedException)
{
this.expectedException = expectedException;
}
public void given() { /** empty implementation */ }
public void when() { /** empty implementation */ }
public void then() { /** empty implementation */ }
public void after() { /** empty implementation */ }
public void run()
{
try
{
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
given();
given();
}
});
if (expectedException == null)
{
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
when();
}
});
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
@@ -886,26 +862,26 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
else
{
doTestInTransaction(new FailureTest(expectedException)
{
{
@Override
public void run() throws Exception
{
when();
}
});
});
}
}
finally
{
{
doTestInTransaction(new VoidTest()
{
{
@Override
public void runImpl() throws Exception
{
after();
after();
}
});
}
}
}
}
}

View File

@@ -122,6 +122,9 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
protected NodeRef recordFolder2;
protected String collabSiteId;
/** admin user name */
protected static final String ADMIN_USER = "admin";
/**
* Indicates whether the test collaboration site should be created
* or not.
@@ -248,7 +251,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
// As system user
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, "rmadmin");
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, ADMIN_USER);
return null;
}

View File

@@ -69,9 +69,9 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
// Create a couple or roles by hand
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5));
//The user can either enter a plain text label or a key to look up in a property file.
filePlanRoleService.createRole(filePlan, role3, "bootstrap.rmadmin.lastName", getListOfCapabilities(5));
filePlanRoleService.createRole(filePlan, role3, "System Administrator", getListOfCapabilities(5));
// create test group
String groupName = GUID.generate();
@@ -102,7 +102,7 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
assertEquals(role2, roleObj.get("name"));
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
checkCapabilities(roleObj, 5);
//Custom role with a user entered message key
roleObj = roles.getJSONObject(role3);
assertNotNull(roleObj);