Merged 5.0.N (5.0.3) to HEAD (5.1/Cloud)

108605: MNT-14413: Merged 5.0.1 (5.0.1.4) to 5.0.N (5.0.3)
      108254: MNT-14366 : Re-created user does not have access to his existing workflows
         - get owner property from initiatorhome nodeRef if initiator nodeRef no longer exists,
      108318: MNT-14366 : Re-created user does not have access to his existing workflows
         - fix for failed tests,
      108467: MNT-14366 : Re-created user does not have access to his existing workflows
         - test to check functionality is working 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@108616 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-07-21 06:31:08 +00:00
parent 4db208e306
commit 01d3791d72
4 changed files with 74 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
/**
* @author Nick Smith
@@ -51,6 +52,8 @@ import org.alfresco.service.namespace.QName;
*/
public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServiceIntegrationTest
{
private final static String USER_RECREATED = "WFUserRecreated" + GUID.generate();
public void testOutcome() throws Exception
{
WorkflowDefinition definition = deployDefinition("alfresco/workflow/review.bpmn20.xml");
@@ -354,6 +357,44 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ
assertEquals("Assign listener was not triggered", new Double(1), assignment1);
}
/**
* Test for MNT-14366
*/
public void testWorkflowRecreatedUser()
{
WorkflowDefinition definition = deployDefinition("alfresco/workflow/review.bpmn20.xml");
personManager.createPerson(USER_RECREATED);
personManager.setUser(USER_RECREATED);
//create an workfow as USER_RECREATED
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
Serializable wfPackage = workflowService.createPackage(null);
params.put(WorkflowModel.ASSOC_PACKAGE, wfPackage);
NodeRef assignee = personManager.get(USER2);
params.put(WorkflowModel.ASSOC_ASSIGNEE, assignee); // task instance field
WorkflowPath path = workflowService.startWorkflow(definition.getId(), params);
String instanceId = path.getInstance().getId();
//check if workflow owner property value is the same as initiator username
WorkflowTask startTask = workflowService.getStartTask(instanceId);
String owner = (String)startTask.getProperties().get(ContentModel.PROP_OWNER);
assertEquals(owner, USER_RECREATED);
//delete and recreate user
personManager.deletePerson(USER_RECREATED);
personManager.createPerson(USER_RECREATED);
personManager.setUser(USER_RECREATED);
//check workflow owner after user deletion and recreation
startTask = workflowService.getStartTask(instanceId);
owner = (String)startTask.getProperties().get(ContentModel.PROP_OWNER);
//owner is now null as nodeRef pointed by initiator property no longer exists;
//user has access to wokflow because owner value is extracted after fix from initiatorhome noderef
assertNull(owner);
workflowService.endTask(startTask.getId(), null);
}
protected String getLongString(int numberOfCharacters) {
StringBuffer stringBuffer = new StringBuffer();
for(int i=0; i<numberOfCharacters/10;i++) {