Skip to content

Commit

Permalink
workflow-impl: fixes for TestAssignmentApproval* tests (mostly UUID)
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Sep 14, 2021
1 parent 6611883 commit 0669259
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -64,34 +64,51 @@ public abstract class AbstractTestAssignmentApproval extends AbstractWfTestPolic
// Roles 1-3 are approved using implicit or global policy rule -- they have no metarole causing approval
// The approval is triggered because Lead 1-3 are set as approvers for these roles.
// There is no approver for role 4 so it does not undertake aby approval.
static final TestResource ROLE1 = new TestResource(TEST_RESOURCE_DIR, "role-role1.xml", "00000001-d34d-b33f-f00d-000000000001");
static final TestResource ROLE2 = new TestResource(TEST_RESOURCE_DIR, "role-role2.xml", "00000001-d34d-b33f-f00d-000000000002");
static final TestResource ROLE3 = new TestResource(TEST_RESOURCE_DIR, "role-role3.xml", "00000001-d34d-b33f-f00d-000000000003");
static final TestResource ROLE4 = new TestResource(TEST_RESOURCE_DIR, "role-role4.xml", "00000001-d34d-b33f-f00d-000000000004");
static final TestResource<ObjectType> ROLE1 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role1.xml", "00000001-d34d-b33f-f00d-000000000001");
static final TestResource<ObjectType> ROLE2 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role2.xml", "00000001-d34d-b33f-f00d-000000000002");
static final TestResource<ObjectType> ROLE3 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role3.xml", "00000001-d34d-b33f-f00d-000000000003");
static final TestResource<ObjectType> ROLE4 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role4.xml", "00000001-d34d-b33f-f00d-000000000004");

// Roles 1b-3b are approved using metarole holding a policy rule that engages users with "special-approver" relation.
// The approval is triggered because Lead 1-3 are set as "special approvers" for these roles.
// There is no approver for role 4 so it does not undertake aby approval.
static final TestResource ROLE1B = new TestResource(TEST_RESOURCE_DIR, "role-role1b.xml", "00000001-d34d-b33f-f00d-00000000001b");
static final TestResource ROLE2B = new TestResource(TEST_RESOURCE_DIR, "role-role2b.xml", "00000001-d34d-b33f-f00d-00000000002b");
static final TestResource ROLE3B = new TestResource(TEST_RESOURCE_DIR, "role-role3b.xml", "00000001-d34d-b33f-f00d-00000000003b");
static final TestResource ROLE4B = new TestResource(TEST_RESOURCE_DIR, "role-role4b.xml", "00000001-d34d-b33f-f00d-00000000004b");
static final TestResource<ObjectType> ROLE1B = new TestResource<>(
TEST_RESOURCE_DIR, "role-role1b.xml", "00000001-d34d-b33f-f00d-00000000001b");
static final TestResource<ObjectType> ROLE2B = new TestResource<>(
TEST_RESOURCE_DIR, "role-role2b.xml", "00000001-d34d-b33f-f00d-00000000002b");
static final TestResource<ObjectType> ROLE3B = new TestResource<>(
TEST_RESOURCE_DIR, "role-role3b.xml", "00000001-d34d-b33f-f00d-00000000003b");
static final TestResource<ObjectType> ROLE4B = new TestResource<>(
TEST_RESOURCE_DIR, "role-role4b.xml", "00000001-d34d-b33f-f00d-00000000004b");

// Note: Role10/10b is induced so it is _not_ being approved. Only direct assignments are covered by approvals.
static final TestResource ROLE10 = new TestResource(TEST_RESOURCE_DIR, "role-role10.xml", "00000001-d34d-b33f-f00d-000000000010");
static final TestResource ROLE10B = new TestResource(TEST_RESOURCE_DIR, "role-role10b.xml", "00000001-d34d-b33f-f00d-00000000010b");
static final TestResource<ObjectType> ROLE10 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role10.xml", "00000001-d34d-b33f-f00d-000000000010");
static final TestResource<ObjectType> ROLE10B = new TestResource<>(
TEST_RESOURCE_DIR, "role-role10b.xml", "00000001-d34d-b33f-f00d-00000000010b");

// delegation for jack-deputy is created only when needed
private static final TestResource USER_JACK_DEPUTY = new TestResource(TEST_RESOURCE_DIR, "user-jack-deputy.xml", "e44769f2-030b-4e9c-9ddf-76bb3a348f9c");
private static final TestResource USER_LEAD1 = new TestResource(TEST_RESOURCE_DIR, "user-lead1.xml", "00000001-d34d-b33f-f00d-L00000000001");
private static final TestResource USER_LEAD1_DEPUTY_1 = new TestResource(TEST_RESOURCE_DIR, "user-lead1-deputy1.xml", "00000001-d34d-b33f-f00d-LD1000000001");
private static final TestResource USER_LEAD1_DEPUTY_2 = new TestResource(TEST_RESOURCE_DIR, "user-lead1-deputy2.xml", "00000001-d34d-b33f-f00d-LD1000000002");
private static final TestResource USER_LEAD2 = new TestResource(TEST_RESOURCE_DIR, "user-lead2.xml", "00000001-d34d-b33f-f00d-L00000000002");
private static final TestResource USER_LEAD3 = new TestResource(TEST_RESOURCE_DIR, "user-lead3.xml", "00000001-d34d-b33f-f00d-L00000000003");
private static final TestResource USER_LEAD10 = new TestResource(TEST_RESOURCE_DIR, "user-lead10.xml", "00000001-d34d-b33f-f00d-L00000000010");
private static final TestResource<ObjectType> USER_JACK_DEPUTY = new TestResource<>(
TEST_RESOURCE_DIR, "user-jack-deputy.xml", "e44769f2-030b-4e9c-9ddf-76bb3a348f9c");
private static final TestResource<ObjectType> USER_LEAD1 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead1.xml", "00000001-d34d-b33f-f00d-a00000000001");
private static final TestResource<ObjectType> USER_LEAD1_DEPUTY_1 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead1-deputy1.xml", "00000001-d34d-b33f-f00d-ad1000000001");
private static final TestResource<ObjectType> USER_LEAD1_DEPUTY_2 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead1-deputy2.xml", "00000001-d34d-b33f-f00d-ad1000000002");
private static final TestResource<ObjectType> USER_LEAD2 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead2.xml", "00000001-d34d-b33f-f00d-a00000000002");
private static final TestResource<ObjectType> USER_LEAD3 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead3.xml", "00000001-d34d-b33f-f00d-a00000000003");
private static final TestResource<ObjectType> USER_LEAD10 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead10.xml", "00000001-d34d-b33f-f00d-a00000000010");

// Draft user. His assignments should undertake approvals just like other users' assignments (MID-6113).
private static final TestResource USER_DRAFT = new TestResource(TEST_RESOURCE_DIR, "user-draft.xml", "e3c00bba-8ce0-4727-a294-91842264c2de");
private static final TestResource<ObjectType> USER_DRAFT = new TestResource<>(TEST_RESOURCE_DIR, "user-draft.xml", "e3c00bba-8ce0-4727-a294-91842264c2de");

protected abstract String getRoleOid(int number);
protected abstract String getRoleName(int number);
Expand Down Expand Up @@ -284,12 +301,12 @@ public void test100AddCreateDelegation() throws Exception {
task.setOwner(userAdministrator);
OperationResult result = getTestOperationResult();

// WHEN
when();
assignDeputy(USER_JACK_DEPUTY.oid, userJackOid, a -> {
//a.beginLimitTargetContent().allowTransitive(true);
}, task, result);

// THEN
then();
PrismObject<UserType> deputy = getUser(USER_JACK_DEPUTY.oid);
display("deputy after", deputy);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.wf.impl.assignments;

import static org.testng.AssertJUnit.assertEquals;

import java.io.File;
import java.util.List;

import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.util.exception.PolicyViolationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import java.io.File;
import java.util.List;

import static org.testng.AssertJUnit.assertEquals;

/**
*
*/
public class TestAssignmentApprovalGlobal extends AbstractTestAssignmentApproval {

private static final File SYSTEM_CONFIGURATION_GLOBAL_FILE = new File(TEST_RESOURCE_DIR, "system-configuration-global.xml");

// Role15 has its approver but there is also a global policy rule that prevents it from being assigned.
private static final TestResource ROLE15 = new TestResource(TEST_RESOURCE_DIR, "role-role15.xml", "00000001-d34d-b33f-f00d-000000000015");

private static final TestResource USER_LEAD15 = new TestResource(TEST_RESOURCE_DIR, "user-lead15.xml", "00000001-d34d-b33f-f00d-L00000000015");
private static final TestResource<ObjectType> ROLE15 = new TestResource<>(
TEST_RESOURCE_DIR, "role-role15.xml", "00000001-d34d-b33f-f00d-000000000015");
private static final TestResource<ObjectType> USER_LEAD15 = new TestResource<>(
TEST_RESOURCE_DIR, "user-lead15.xml", "00000001-d34d-b33f-f00d-a00000000015");

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
Expand All @@ -47,25 +46,37 @@ protected File getSystemConfigurationFile() {
@Override
protected String getRoleOid(int number) {
switch (number) {
case 1: return ROLE1.oid;
case 2: return ROLE2.oid;
case 3: return ROLE3.oid;
case 4: return ROLE4.oid;
case 10: return ROLE10.oid;
default: throw new IllegalArgumentException("Wrong role number: " + number);
case 1:
return ROLE1.oid;
case 2:
return ROLE2.oid;
case 3:
return ROLE3.oid;
case 4:
return ROLE4.oid;
case 10:
return ROLE10.oid;
default:
throw new IllegalArgumentException("Wrong role number: " + number);
}
}

@SuppressWarnings("Duplicates")
@Override
protected String getRoleName(int number) {
switch (number) {
case 1: return "Role1";
case 2: return "Role2";
case 3: return "Role3";
case 4: return "Role4";
case 10: return "Role10";
default: throw new IllegalArgumentException("Wrong role number: " + number);
case 1:
return "Role1";
case 2:
return "Role2";
case 3:
return "Role3";
case 4:
return "Role4";
case 10:
return "Role10";
default:
throw new IllegalArgumentException("Wrong role number: " + number);
}
}

Expand All @@ -88,5 +99,4 @@ public void test300ApprovalAndEnforce() throws Exception {
display("current work items", currentWorkItems);
assertEquals("Wrong # of current work items", 0, currentWorkItems.size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
oid="00000001-d34d-b33f-f00d-M00000000001">
oid="00000001-d34d-b33f-f00d-b00000000001">
<name>Metarole 1 'default'</name>
<description>Treats assignments and modifications in the default way (but with specific approver/owner relations)</description>
<inducement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<name>Role22</name>
<description>Special approval (org:special-approver)</description>
<assignment> <!-- metarole-default -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
</role>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>Role23</name>
<description>Special + security approval (org:special-approver, org:security-approver)</description>
<assignment> <!-- metarole-default -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<assignment> <!-- metarole-security -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000002" type="RoleType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
oid="00000001-d34d-b33f-f00d-000000000024">
<name>Role24</name>
<assignment> <!-- metarole-default -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<assignment>
<policyRule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
oid="00000001-d34d-b33f-f00d-M00000000001">
oid="00000001-d34d-b33f-f00d-b00000000001">
<name>Metarole 1 'default'</name>
<description>Treats assignments and modifications in the default way (but with specific approver/owner relations)</description>
<inducement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<name>Role10b</name>
<description>Induced by Role1b</description>
<assignment> <!-- metarole 1 'default' -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<delegable>true</delegable>
</role>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
oid="00000001-d34d-b33f-f00d-00000000001b">
<name>Role1b</name>
<assignment> <!-- metarole 1 'default' -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<activation>
<administrativeStatus>disabled</administrativeStatus>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
oid="00000001-d34d-b33f-f00d-00000000002b">
<name>Role2b</name>
<assignment> <!-- metarole 1 'default' -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<delegable>true</delegable>
</role>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
oid="00000001-d34d-b33f-f00d-00000000003b">
<name>Role3b</name>
<assignment> <!-- metarole 1 'default' -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<delegable>true</delegable>
</role>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
oid="00000001-d34d-b33f-f00d-00000000004b">
<name>Role4b</name>
<assignment> <!-- metarole 1 'default' -->
<targetRef oid="00000001-d34d-b33f-f00d-M00000000001" type="RoleType"/>
<targetRef oid="00000001-d34d-b33f-f00d-b00000000001" type="RoleType"/>
</assignment>
<delegable>true</delegable>
</role>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-LD1000000001">
<user oid="00000001-d34d-b33f-f00d-ad1000000001">
<name>lead1-deputy1</name>
<assignment>
<targetRef oid="00000001-d34d-b33f-f00d-L00000000001" type="UserType" relation="deputy"/>
<targetRef oid="00000001-d34d-b33f-f00d-a00000000001" type="UserType" relation="deputy"/>
</assignment>
<fullName>Lead1 Deputy1</fullName>
<familyName>Lead1 Deputy1</familyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-LD1000000002">
<user oid="00000001-d34d-b33f-f00d-ad1000000002">
<name>lead1-deputy2</name>
<assignment>
<targetRef oid="00000001-d34d-b33f-f00d-L00000000001" type="UserType" relation="deputy"/>
<targetRef oid="00000001-d34d-b33f-f00d-a00000000001" type="UserType" relation="deputy"/>
</assignment>
<fullName>Lead1 Deputy2</fullName>
<familyName>Lead1 Deputy2</familyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-L00000000001" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<user oid="00000001-d34d-b33f-f00d-a00000000001" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<name>lead1</name>
<assignment> <!-- approver -->
<targetRef oid="00000000-0000-0000-0000-00000000000a" type="RoleType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-L00000000010">
<user oid="00000001-d34d-b33f-f00d-a00000000010">
<name>lead10</name>
<assignment> <!-- approver -->
<targetRef oid="00000000-0000-0000-0000-00000000000a" type="RoleType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-L00000000015">
<user oid="00000001-d34d-b33f-f00d-a00000000015">
<name>lead15</name>
<assignment> <!-- approver -->
<targetRef oid="00000000-0000-0000-0000-00000000000a" type="RoleType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-L00000000002">
<user oid="00000001-d34d-b33f-f00d-a00000000002">
<name>lead2</name>
<assignment> <!-- approver -->
<targetRef oid="00000000-0000-0000-0000-00000000000a" type="RoleType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="00000001-d34d-b33f-f00d-L00000000003">
<user oid="00000001-d34d-b33f-f00d-a00000000003">
<name>lead3</name>
<assignment> <!-- approver -->
<targetRef oid="00000000-0000-0000-0000-00000000000a" type="RoleType"/>
Expand Down
4 changes: 2 additions & 2 deletions model/workflow-impl/src/test/resources/escalation/role-e2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<script>
<code>
def approverMap = [
'6f007608-415b-49e3-b388-0217d535fc7d':'00000001-d34d-b33f-f00d-LD1000000001',
'53b49582-de4b-4306-a135-41f46e64cbcc':'00000001-d34d-b33f-f00d-LD1000000002'
'6f007608-415b-49e3-b388-0217d535fc7d':'00000001-d34d-b33f-f00d-ad1000000001',
'53b49582-de4b-4306-a135-41f46e64cbcc':'00000001-d34d-b33f-f00d-ad1000000002'
]
approverMap[workItem?.originalAssigneeRef?.oid]
</code>
Expand Down

0 comments on commit 0669259

Please sign in to comment.