/
TestMultiConnectorResources.java
121 lines (97 loc) · 4.95 KB
/
TestMultiConnectorResources.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (c) 2010-2017 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.model.intest.multi;
import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.FailableRunnable;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;
import java.io.File;
import java.util.List;
import static org.testng.AssertJUnit.*;
/**
* Test resources that have several connectors.
*
* MID-5921
*
* @author semancik
*
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestMultiConnectorResources extends AbstractConfiguredModelIntegrationTest {
public static final File TEST_DIR = new File("src/test/resources/multi-connector");
private static Trace LOGGER = TraceManager.getTrace(TestMultiConnectorResources.class);
// Black dummy resource for testing tolerant attributes
protected static final File RESOURCE_DUMMY_OPALINE_FILE = new File(TEST_DIR, "resource-dummy-opaline.xml");
protected static final String RESOURCE_DUMMY_OPALINE_OID = "d4a2a030-0a1c-11ea-b61c-67d35cfea30f";
protected static final String RESOURCE_DUMMY_OPALINE_NAME = "opaline";
protected static final String RESOURCE_DUMMY_OPALINE_SCRIPT_NAME = "opaline-script";
protected static final String RESOURCE_DUMMY_OPALINE_NAMESPACE = MidPointConstants.NS_RI;
private static final String CONF_USELESS_OPALINE = "USEless-opaline";
private static final String CONF_USELESS_SCRIPT = "USEless-script";
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
initDummyResourcePirate(RESOURCE_DUMMY_OPALINE_NAME, RESOURCE_DUMMY_OPALINE_FILE, RESOURCE_DUMMY_OPALINE_OID, initTask, initResult);
repoAddObjectFromFile(SECURITY_POLICY_FILE, initResult);
repoAddObjectFromFile(PASSWORD_POLICY_BENEVOLENT_FILE, initResult);
repoAddObjectFromFile(USER_JACK_FILE, true, initResult);
repoAddObjectFromFile(USER_GUYBRUSH_FILE, true, initResult);
}
@Test(enabled = false) // MID-5921
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
// WHEN
OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OPALINE_OID, task);
// THEN
display("Test result", testResult);
TestUtil.assertSuccess("Opaline dummy test result", testResult);
// Makes sure that both resources are configured
assertEquals("Wrong OPALINE useless string", CONF_USELESS_OPALINE, getDummyResource(RESOURCE_DUMMY_OPALINE_NAME).getUselessString());
assertEquals("Wrong OPALINE-SCRIPT useless string", CONF_USELESS_SCRIPT, getDummyResource(RESOURCE_DUMMY_OPALINE_SCRIPT_NAME).getUselessString());
}
@Test(enabled = false) // MID-5921
public void test100JackAssignDummyOpaline() throws Exception {
final String TEST_NAME = "test100JackAssignDummyOpaline";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OPALINE_OID, null, task, result);
// THEN
assertSuccess(result);
assertUserAfter(USER_JACK_OID)
.singleLink()
.target()
.assertResource(RESOURCE_DUMMY_OPALINE_OID)
.assertName(ACCOUNT_JACK_DUMMY_USERNAME);
assertDummyAccountByUsername(RESOURCE_DUMMY_OPALINE_NAME, ACCOUNT_JACK_DUMMY_USERNAME)
.assertFullName(USER_JACK_FULL_NAME);
}
}