Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 5, 2020
2 parents 4a99b9d + c76925f commit 5a1aab6
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 196 deletions.

Large diffs are not rendered by default.

Expand Up @@ -117,6 +117,7 @@
import com.evolveum.midpoint.test.*;
import com.evolveum.midpoint.test.asserter.*;
import com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter;
import com.evolveum.midpoint.test.ldap.OpenDJController;
import com.evolveum.midpoint.test.util.MidPointAsserts;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.*;
Expand Down Expand Up @@ -4365,7 +4366,7 @@ protected void assertDummyAccountNoAttribute(String dummyInstanceName, String us
protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException {
Entry entry = openDJController.searchByUid(uid);
assertNotNull("OpenDJ accoun with uid " + uid + " not found", entry);
openDJController.assertAttribute(entry, "cn", cn);
OpenDJController.assertAttribute(entry, "cn", cn);
if (active != null) {
openDJController.assertActive(entry, active);
}
Expand Down Expand Up @@ -4543,33 +4544,20 @@ protected void loginAnonymous() {
SecurityContextHolder.getContext().setAuthentication(createMpAuthentication(authentication));
}

protected void assertLoggedInUsername(String username) {
protected void assertLoggedInUsername(@NotNull String username) {
MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal();
FocusType user = midPointPrincipal.getFocus();
if (user == null) {
if (username == null) {
return;
} else {
AssertJUnit.fail("Expected logged in user '" + username + "' but there was no user in the spring security context");
}
}
assertEquals("Wrong logged-in user", username, user.getName().getOrig());
}

protected void assertLoggedInUserOid(String userOid) {
protected void assertLoggedInUserOid(@NotNull String userOid) {
MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal();
assertPrincipalUserOid(midPointPrincipal, userOid);
}

protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOid) {
protected void assertPrincipalUserOid(
@NotNull MidPointPrincipal principal, @NotNull String userOid) {
FocusType user = principal.getFocus();
if (user == null) {
if (userOid == null) {
return;
} else {
AssertJUnit.fail("Expected user " + userOid + " in principal " + principal + " but there was none");
}
}
assertEquals("Wrong user OID in principal", userOid, user.getOid());
}

Expand Down
Expand Up @@ -26,8 +26,6 @@
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
Expand Down Expand Up @@ -69,7 +67,6 @@ public void listNonExistingOwner() throws Exception {

@Test
public void testLinkUnlink() throws Exception {
logger.info("==[testLinkUnlink]==");
// GIVEN
OperationResult result = new OperationResult("testLinkUnlink");
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(FOLDER_BASIC, "user.xml"));
Expand Down
Expand Up @@ -22,15 +22,10 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskExecutionStatus;
import com.evolveum.midpoint.test.util.MidPointTestConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationStatsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* @author katka
*
*/
@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
Expand All @@ -46,7 +41,6 @@ public abstract class TestThresholds extends AbstractStoryTest {
private static final File LDIF_CREATE_USERS_NEXT_FILE = new File(TEST_DIR, "users-next.ldif");
private static final File LDIF_CHANGE_ACTIVATION_FILE = new File(TEST_DIR, "users-activation.ldif");


private static final File ROLE_POLICY_RULE_CREATE_FILE = new File(TEST_DIR, "role-policy-rule-create.xml");
private static final String ROLE_POLICY_RULE_CREATE_OID = "00000000-role-0000-0000-999111111112";

Expand All @@ -58,21 +52,17 @@ public abstract class TestThresholds extends AbstractStoryTest {

private static final int TASK_IMPORT_TIMEOUT = 60000;


private PrismObject<ResourceType> resourceOpenDj;

protected int getDefaultUsers() {
return 6;
}


@Override
protected void startResources() throws Exception {
openDJController.startCleanServer();
}

@AfterClass
public static void stopResources() throws Exception {
public static void stopResources() {
openDJController.stop();
}

Expand All @@ -83,13 +73,13 @@ public static void stopResources() throws Exception {
protected abstract void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) throws Exception;
protected abstract void assertSynchronizationStatisticsActivation(Task taskAfter);


@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

//Resources
resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
PrismObject<ResourceType> resourceOpenDj = importAndGetObjectFromFile(
ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
openDJController.setResource(resourceOpenDj);

repoAddObjectFromFile(ROLE_POLICY_RULE_CREATE_FILE, initResult);
Expand All @@ -98,10 +88,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
repoAddObjectFromFile(getTaskFile(), initResult);
}


@Test
public void test001testImportBaseUsers() throws Exception {
final String TEST_NAME = "test001testImportBaseUsers";
OperationResult result = createOperationResult();

importObjectFromFile(TASK_IMPORT_BASE_USERS_FILE);
Expand Down Expand Up @@ -141,10 +129,8 @@ protected int getNumberOfUsers() {

@Test
public void test100assignPolicyRuleCreateToTask() throws Exception {
final String TEST_NAME = "test100assignPolicyRuleCreateToTask";

// WHEN
Task task = taskManager.createTaskInstance(TEST_NAME);
Task task = createPlainTask();
OperationResult result = task.getResult();
assignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CREATE_OID, task, result);

Expand All @@ -159,15 +145,11 @@ public void test100assignPolicyRuleCreateToTask() throws Exception {

@Test
public void test110importAccounts() throws Exception {
final String TEST_NAME = "test110importAccountsSimulate";

Task task = taskManager.createTaskInstance(TEST_NAME);
Task task = createPlainTask();
OperationResult result = task.getResult();

openDJController.addEntriesFromLdifFile(LDIF_CREATE_USERS_FILE);



assertUsers(getNumberOfUsers());
//WHEN
when();
Expand All @@ -180,27 +162,23 @@ public void test110importAccounts() throws Exception {

Task taskAfter = taskManager.getTaskWithResult(getTaskOid(), result);
assertSynchronizationStatisticsAfterImport(taskAfter);

}

@Test
public void test111importAccountsAgain() throws Exception {
final String TEST_NAME = "test111importAccountsAgain";

Task task = taskManager.createTaskInstance(TEST_NAME);
Task task = createPlainTask();
OperationResult result = task.getResult();

openDJController.addEntriesFromLdifFile(LDIF_CREATE_USERS_NEXT_FILE);



assertUsers(getNumberOfUsers()+getProcessedUsers());
assertUsers(getNumberOfUsers() + getProcessedUsers());
//WHEN
when();
OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT);
assertFailure(reconResult);

//THEN
assertUsers(getProcessedUsers()*2 + getNumberOfUsers());
assertUsers(getProcessedUsers() * 2 + getNumberOfUsers());
assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED);

Task taskAfter = taskManager.getTaskWithResult(getTaskOid(), result);
Expand All @@ -209,11 +187,9 @@ public void test111importAccountsAgain() throws Exception {
}

@Test
public void test500chageTaskPolicyRule() throws Exception {
final String TEST_NAME = "test500chageTaskPolicyRule";

public void test500changeTaskPolicyRule() throws Exception {
//WHEN
Task task = taskManager.createTaskInstance(TEST_NAME);
Task task = createPlainTask();
OperationResult result = task.getResult();
unassignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CREATE_OID, task, result);
assignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CHANGE_ACTIVATION_OID, task, result);
Expand All @@ -226,10 +202,8 @@ public void test500chageTaskPolicyRule() throws Exception {
assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED);
}


@Test
public void test520changeActivationThreeAccounts() throws Exception {
final String TEST_NAME = "test520changeActivationThreeAccounts";
OperationResult result = createOperationResult();

//GIVEN
Expand All @@ -247,7 +221,5 @@ public void test520changeActivationThreeAccounts() throws Exception {
assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED);

assertSynchronizationStatisticsActivation(taskAfter);

}

}
Expand Up @@ -15,21 +15,18 @@
import org.springframework.test.context.ContextConfiguration;

import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IterativeTaskInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationInformationType;

/**
* @author katka
*
*/
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"})
@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestThresholdsLiveSyncFull extends TestThresholds {

private static final File TASK_LIVESYNC_OPENDJ_FULL_FILE = new File(TEST_DIR, "task-opendj-livesync-full.xml");
private static final String TASK_LIVESYNC_OPENDJ_FULL_OID = "10335c7c-838f-11e8-93a6-4b1dd0ab58e4";


@Override
protected File getTaskFile() {
return TASK_LIVESYNC_OPENDJ_FULL_FILE;
Expand Down
Expand Up @@ -15,21 +15,18 @@
import org.springframework.test.context.ContextConfiguration;

import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IterativeTaskInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationInformationType;

/**
* @author katka
*
*/
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"})
@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestThresholdsLiveSyncSimulate extends TestThresholds {

private static final File TASK_LIVESYNC_OPENDJ_SIMULATE_FILE = new File(TEST_DIR, "task-opendj-livesync-simulate.xml");
private static final String TASK_LIVESYNC_OPENDJ_SIMULATE_OID = "10335c7c-838f-11e8-93a6-4b1dd0ab58e4";


@Override
protected File getTaskFile() {
return TASK_LIVESYNC_OPENDJ_SIMULATE_FILE;
Expand Down Expand Up @@ -79,6 +76,4 @@ protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter)
assertEquals(syncInfo.getCountLinkedAfter(), 0);
assertEquals(syncInfo.getCountUnlinkedAfter(), 0);
}


}
Expand Up @@ -20,17 +20,12 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskExecutionStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IterativeTaskInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* @author katka
*
*/
@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"})
@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestThresholdsReconFull extends TestThresholds {

Expand Down Expand Up @@ -67,11 +62,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
}

@Test
public void test600chageTaskPolicyRule() throws Exception {
final String TEST_NAME = "test600chageTaskPolicyRule";

public void test600changeTaskPolicyRule() throws Exception {
//WHEN
Task task = taskManager.createTaskInstance(TEST_NAME);
Task task = createPlainTask();
OperationResult result = task.getResult();
assignRole(TaskType.class, TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, ROLE_POLICY_RULE_DELETE_OID, task, result);

Expand All @@ -83,10 +76,8 @@ public void test600chageTaskPolicyRule() throws Exception {
assertTaskExecutionStatus(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, TaskExecutionStatus.SUSPENDED);
}


@Test
public void test610testFullRecon() throws Exception {
final String TEST_NAME = "test610testFullRecon";
OperationResult result = createOperationResult();

//WHEN
Expand All @@ -103,10 +94,8 @@ public void test610testFullRecon() throws Exception {

}


@Test
public void test611testFullRecon() throws Exception {
final String TEST_NAME = "test611testFullRecon";
OperationResult result = createOperationResult();

openDJController.delete("uid=user10,ou=People,dc=example,dc=com");
Expand Down Expand Up @@ -150,9 +139,8 @@ public void test611testFullRecon() throws Exception {

}


@Override
protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws Exception {
protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) {
IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation();
assertEquals(infoType.getTotalFailureCount(), 1);

Expand All @@ -169,7 +157,7 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws
assertEquals(syncInfo.getCountUnlinked(), 0);
}

private void assertSynchronizationStatisticsFull(Task taskAfter) throws Exception {
private void assertSynchronizationStatisticsFull(Task taskAfter) {
IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation();
assertEquals(infoType.getTotalFailureCount(), 0);
assertNull(taskAfter.getWorkState(), "Unexpected work state in task.");
Expand All @@ -180,20 +168,20 @@ private void assertSynchronizationStatisticsFull(Task taskAfter) throws Exceptio
* @see com.evolveum.midpoint.testing.story.TestThresholds#assertSynchronizationStatisticsAfterSecondImport(com.evolveum.midpoint.task.api.Task)
*/
@Override
protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) throws Exception {
protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) {
IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation();
assertEquals(infoType.getTotalFailureCount(), 1);

SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation();

assertEquals(syncInfo.getCountUnmatched(), 5);
assertEquals(syncInfo.getCountDeleted(), 0);
assertEquals(syncInfo.getCountLinked(), getDefaultUsers()+getProcessedUsers());
assertEquals(syncInfo.getCountLinked(), getDefaultUsers() + getProcessedUsers());
assertEquals(syncInfo.getCountUnlinked(), 0);

assertEquals(syncInfo.getCountUnmatchedAfter(), 0);
assertEquals(syncInfo.getCountDeleted(), 0);
assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers() + getProcessedUsers()*2);
assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers() + getProcessedUsers() * 2);
assertEquals(syncInfo.getCountUnlinked(), 0);
}

Expand All @@ -211,5 +199,4 @@ protected void assertSynchronizationStatisticsActivation(Task taskAfter) {
assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), 14);
assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0);
}

}

0 comments on commit 5a1aab6

Please sign in to comment.