mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
76582: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud) 76493: MNT-11670: Merged DEV to V4.2-BUG-FIX (4.2.4) 73830: MNT-11670: Unable to end a workflow when a timer is triggered and a rule is configured on a target folder - Save current user info when rule is added to the pending execution. Then it can be used during rule execution if security context is empty. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77648 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -1187,4 +1187,53 @@ public class RuleServiceImplTest extends BaseRuleTest
|
||||
this.nodeService.deleteNode(folder2NodeRef);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-11670
|
||||
*/
|
||||
public void testRuleExecutionWhenSecurityContextIsEmpty() throws Exception
|
||||
{
|
||||
// Create parent and child folders
|
||||
NodeRef parentNodeRef = this.nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("parentnode" + GUID.generate()), ContentModel.TYPE_FOLDER)
|
||||
.getChildRef();
|
||||
|
||||
// rule is created and added to pending execution by any user
|
||||
assertNotNull(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
|
||||
// Create rule for child node
|
||||
Rule testRule = new Rule();
|
||||
testRule.setRuleTypes(Collections.singletonList(RuleType.INBOUND));
|
||||
testRule.setTitle("RuleServiceTest" + GUID.generate());
|
||||
testRule.setDescription(DESCRIPTION);
|
||||
testRule.applyToChildren(true);
|
||||
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
||||
action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||
testRule.setAction(action);
|
||||
this.ruleService.saveRule(parentNodeRef, testRule);
|
||||
assertNotNull("Rule was not saved", testRule.getNodeRef());
|
||||
|
||||
// Search rules
|
||||
List<Rule> rules = this.ruleService.getRules(parentNodeRef, true, testRule.getRuleTypes().get(0));
|
||||
assertNotNull("No rules found", rules);
|
||||
assertTrue("Created rule is not found", new HashSet<Rule>(rules).contains(testRule));
|
||||
|
||||
// New node
|
||||
NodeRef actionedUponNodeRef = this.nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("actioneduponnode" + GUID.generate()),
|
||||
ContentModel.TYPE_CONTENT).getChildRef();
|
||||
|
||||
// Queue the rule to be executed later and execute pending rules
|
||||
if (this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE))
|
||||
{
|
||||
this.nodeService.removeAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
((RuntimeRuleService) ruleService).addRulePendingExecution(parentNodeRef, actionedUponNodeRef, testRule);
|
||||
|
||||
// no security context in case of the issue
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
assertNull(AuthenticationUtil.getFullyAuthenticatedUser());
|
||||
assertNull(AuthenticationUtil.getRunAsUser());
|
||||
|
||||
((RuntimeRuleService) ruleService).executePendingRules();
|
||||
assertTrue("Pending rule was not executed", this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user