Skip to content

Commit

Permalink
Add non-iterative bulk actions EP test
Browse files Browse the repository at this point in the history
Just for sure.
  • Loading branch information
mederly committed Aug 25, 2023
1 parent 6a46ced commit 97b8d7e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class TestTrustedBulkActions extends AbstractStoryTest {

private static final TestTask TASK_TEMPLATE_SCRIPTING_NO_PROFILE = new TestTask(
TEST_DIR, "task-template-scripting-no-profile.xml", "f38b71ad-e212-4c46-8594-032202e0e9b9");
private static final TestTask TASK_TEMPLATE_SCRIPTING_NO_PROFILE_NON_ITERATIVE = new TestTask(
TEST_DIR, "task-template-scripting-no-profile-non-iterative.xml", "bf575791-eabd-438e-855e-09824a99b088");
private static final TestTask TASK_TEMPLATE_SCRIPTING_TRUSTED = new TestTask(
TEST_DIR, "task-template-scripting-trusted.xml", "a801db00-cd4b-4998-a08b-3b964b9d7cf1");
private static final TestTask TASK_TEMPLATE_SCRIPTING_LITTLE_TRUSTED = new TestTask(
Expand Down Expand Up @@ -84,6 +86,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
ARCHETYPE_LITTLE_TRUSTED_TASK,
ARCHETYPE_TRUSTED_ROLE,
TASK_TEMPLATE_SCRIPTING_NO_PROFILE,
TASK_TEMPLATE_SCRIPTING_NO_PROFILE_NON_ITERATIVE,
TASK_TEMPLATE_SCRIPTING_TRUSTED,
TASK_TEMPLATE_SCRIPTING_LITTLE_TRUSTED,
TASK_TEMPLATE_SCRIPTING_LITTLE_TRUSTED_RUN_PRIVILEGED,
Expand Down Expand Up @@ -124,6 +127,30 @@ public void test100TemplateWithoutProfile() throws CommonException {
FLAG.assertNotSet();
}

/** Baseline: the same as above for non-iterative task. It should fail. */
@Test
public void test105TemplateWithoutProfileNonIterative() throws CommonException {
var task = getTestTask();
var result = task.getResult();
login(USER_JOE.getNameOrig());
FLAG.reset();

when("task template is instantiated");
var taskOid = modelInteractionService.submitTaskFromTemplate(
TASK_TEMPLATE_SCRIPTING_NO_PROFILE_NON_ITERATIVE.oid,
ActivityCustomization.none(),
task, result);
waitForTaskCloseOrSuspend(taskOid, 30000L);

then("the execution is not successful");
assertTask(taskOid, "after")
.display()
.assertFatalError()
.assertResultMessageContains("Access to script expression evaluator not allowed");

FLAG.assertNotSet();
}

/** Now trying to run script from within task template with `trusted` expression profile. It should work. */
@Test
public void test110TemplateWithTrustedProfile() throws CommonException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
~ Copyright (C) 2010-2023 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<task xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
oid="bf575791-eabd-438e-855e-09824a99b088">
<name>template-scripting-no-profile-non-iterative</name>
<executionState>waiting</executionState>
<activity>
<work>
<nonIterativeScripting>
<scriptExecutionRequest>
<s:execute>
<s:forWholeInput>true</s:forWholeInput>
<s:script>
<code>
import com.evolveum.midpoint.testing.story.TestTrustedBulkActions

TestTrustedBulkActions.FLAG.set()
log.info('executed')
</code>
</s:script>
</s:execute>
</scriptExecutionRequest>
</nonIterativeScripting>
</work>
</activity>
</task>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
~ and European Union Public License. See LICENSE file for details.
-->

<!--suppress UnnecessaryQualifiedReference -->
<task xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"
oid="f38b71ad-e212-4c46-8594-032202e0e9b9">
Expand All @@ -17,10 +16,11 @@
<scriptExecutionRequest>
<s:execute>
<s:script>
<code>import com.evolveum.midpoint.testing.story.TestTrustedBulkActions
<code>
import com.evolveum.midpoint.testing.story.TestTrustedBulkActions

TestTrustedBulkActions.FLAG.set()
log.info('executed')
TestTrustedBulkActions.FLAG.set()
log.info('executed')
</code>
</s:script>
</s:execute>
Expand Down

0 comments on commit 97b8d7e

Please sign in to comment.