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
tchrapovic committed Mar 24, 2023
2 parents 5944ed0 + 1303c89 commit 8169487
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public interface CommonInitialObjects {
TestObject<ArchetypeType> ARCHETYPE_OBJECT_MARK = TestObject.classPath(
ARCHETYPES, "701-archetype-object-mark.xml", SystemObjectsType.ARCHETYPE_OBJECT_MARK.value());

TestObject<ArchetypeType> ARCHETYPE_RECONCILIATION_TASK = TestObject.classPath(
ARCHETYPES, "501-archetype-task-reconciliation.xml",
SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value());

TestObject<ArchetypeType> ARCHETYPE_IMPORT_TASK = TestObject.classPath(
ARCHETYPES, "503-archetype-task-import.xml",
SystemObjectsType.ARCHETYPE_IMPORT_TASK.value());

TestObject<ArchetypeType> ARCHETYPE_ITERATIVE_BULK_ACTION_TASK = TestObject.classPath(
ARCHETYPES, "509-archetype-task-iterative-bulk-action.xml",
SystemObjectsType.ARCHETYPE_ITERATIVE_BULK_ACTION_TASK.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
super.initSystem(initTask, initResult);

try {
repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
repoAddObjectFromFile(getSystemConfigurationFile(), initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" +
"looks like the previous test haven't cleaned it up", e);
Expand All @@ -89,6 +89,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
CommonInitialObjects.ARCHETYPE_OBJECT_MARK.init(this, initTask, initResult);
CommonInitialObjects.MARK_PROTECTED.init(this, initTask, initResult);
}

CommonInitialObjects.ARCHETYPE_RECONCILIATION_TASK.init(this, initTask, initResult);
CommonInitialObjects.ARCHETYPE_IMPORT_TASK.init(this, initTask, initResult);
}

protected File getSystemConfigurationFile() {
return SYSTEM_CONFIGURATION_FILE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.nio.charset.StandardCharsets;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.test.CommonInitialObjects;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.opends.server.types.Entry;
Expand All @@ -25,7 +23,6 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand All @@ -39,25 +36,16 @@
*/
@ContextConfiguration(locations = { "classpath:ctx-longtest-test-main.xml" })
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class TestGenericSynchronization extends AbstractModelIntegrationTest { // TODO Why not from AbstractLongTest?

private static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml");
private static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value();
public class TestGenericSynchronization extends AbstractLongTest {

private static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml");
private static final String USER_ADMINISTRATOR_OID = SystemObjectsType.USER_ADMINISTRATOR.value();
private static final String USER_ADMINISTRATOR_USERNAME = "administrator";

private static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml");
private static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004";

private static final File RESOURCE_OPENDJ_FILE = new File(COMMON_DIR, "resource-opendj-generic-sync.xml");
private static final String RESOURCE_OPENDJ_NAME = "Localhost OpenDJ";
private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000030";
private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI;

public static final File OBJECT_TEMPLATE_ORG_FILE = new File(COMMON_DIR, "object-template-org.xml");
public static final String OBJECT_TEMPLATE_ORG_OID = "10000000-0000-0000-0000-000000000231";
private static final File OBJECT_TEMPLATE_ORG_FILE = new File(COMMON_DIR, "object-template-org.xml");
private static final String OBJECT_TEMPLATE_ORG_OID = "10000000-0000-0000-0000-000000000231";

//222 org. units, 2160 users
// private static final int[] TREE_LEVELS = {2, 5, 7, 2};
Expand All @@ -79,17 +67,13 @@ public class TestGenericSynchronization extends AbstractModelIntegrationTest { /
private int ldapdUserCount = 4;
private int ldapOrgCount = 0;

private PrismObject<ResourceType> resourceOpenDj;

private boolean logCreateEntry = true;

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

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

Expand All @@ -99,26 +83,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti

loadOpenDJWithData();

// System Configuration and administrator
repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);

modelService.postInit(initResult);

PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
login(userAdministrator);

if (areMarksSupported()) {
CommonInitialObjects.ARCHETYPE_OBJECT_MARK.init(this, initTask, initResult);
CommonInitialObjects.MARK_PROTECTED.init(this, initTask, initResult);
}

importObjectFromFile(OBJECT_TEMPLATE_ORG_FILE, initResult);
setDefaultObjectTemplate(OrgType.COMPLEX_TYPE, OBJECT_TEMPLATE_ORG_OID);

// 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);

assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
Expand All @@ -132,6 +102,7 @@ private void loadOpenDJWithData() throws IOException, LDIFException {
IntegrationTestTools.display("Loaded " + count + " LDAP entries in " + ((ldapPopEnd - ldapPopStart) / 1000) + " seconds");
}

@SuppressWarnings("SameParameterValue")
private int loadOpenDJ(int[] TREE_SIZE, int[] USER_COUNT, String dnSuffix, int count)
throws IOException, LDIFException {

Expand Down Expand Up @@ -169,6 +140,8 @@ private int loadOpenDJ(int[] TREE_SIZE, int[] USER_COUNT, String dnSuffix, int c
}

private void logCreateEntry(Entry entry) {
boolean logCreateEntry = true;
//noinspection ConstantValue
if (logCreateEntry) {
System.out.println("Creating LDAP entry: " + entry.getDN());
logger.trace("Creating LDAP entry: {}", entry.getDN());
Expand All @@ -185,8 +158,7 @@ private Entry createUserEntry(String uid, String suffix, String sn) throws IOExc
+ "sn: " + sn + '\n';
LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb, StandardCharsets.UTF_8));
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry ldifEntry = ldifReader.readEntry();
return ldifEntry;
return ldifReader.readEntry();
}

private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFException {
Expand All @@ -197,8 +169,7 @@ private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFE
+ "description: " + "This is sparta! ...or " + ou + "\n";
LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb, StandardCharsets.UTF_8));
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry ldifEntry = ldifReader.readEntry();
return ldifEntry;
return ldifReader.readEntry();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import java.nio.charset.StandardCharsets;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.test.CommonInitialObjects;

import org.apache.commons.io.IOUtils;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
Expand All @@ -31,7 +29,6 @@
import com.evolveum.midpoint.common.ProfilingConfigurationManager;
import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
import com.evolveum.midpoint.model.impl.sync.tasks.recon.ReconciliationLauncher;
import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.internals.InternalsConfig;
Expand All @@ -43,30 +40,19 @@
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

@ContextConfiguration(locations = { "classpath:ctx-longtest-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestLdapUniversity extends AbstractModelIntegrationTest { // TODO Why not from AbstractLongTest?

public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml");

protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml");
protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002";
public class TestLdapUniversity extends AbstractLongTest {

protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml");

protected static final File RESOURCE_OPENDJ_FILE = new File(COMMON_DIR, "resource-opendj-university.xml");
protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003";
protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI;
private static final File RESOURCE_OPENDJ_FILE = new File(COMMON_DIR, "resource-opendj-university.xml");
private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003";
private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI;

// Make it at least 1501 so it will go over the 3000 entries size limit
private static final int NUM_LDAP_ENTRIES = 3100;

protected ResourceType resourceOpenDjType;
protected PrismObject<ResourceType> resourceOpenDj;

@Autowired private ReconciliationLauncher reconciliationLauncher;
@Autowired private MidpointConfiguration midpointConfiguration;

Expand All @@ -84,33 +70,14 @@ public static void stopResources() {
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

// System Configuration
PrismObject<SystemConfigurationType> config;
try {
config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" +
"looks like the previous test haven't cleaned it up", e);
}
modelService.postInit(initResult);

var config = getSystemConfiguration();
LoggingConfigurationManager.configure(
ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
config.asObjectable().getVersion(), midpointConfiguration, initResult);

// administrator
PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
login(userAdministrator);

if (areMarksSupported()) {
CommonInitialObjects.ARCHETYPE_OBJECT_MARK.init(this, initTask, initResult);
CommonInitialObjects.MARK_PROTECTED.init(this, initTask, initResult);
}
ProfilingConfigurationManager.checkSystemProfilingConfiguration(
config.asPrismObject()), config.getVersion(), midpointConfiguration, initResult);

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

assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
Expand Down Expand Up @@ -206,6 +173,7 @@ public void test120BigReconciliation() throws Exception {
assertUser("e1(u1)");
}

@SuppressWarnings("SameParameterValue")
private void loadEntries(String prefix) throws LDIFException, IOException {
long ldapPopStart = System.currentTimeMillis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,27 @@
*/
package com.evolveum.midpoint.testing.longtest;

import java.io.File;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

/**
* @author lazyman
*/
@ContextConfiguration(locations = { "classpath:ctx-longtest-test-main.xml" })
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class TestOrgHierarchy extends AbstractModelIntegrationTest {

private static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml");
private static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value();

private static final File USER_ADMINISTRATOR_FILENAME = new File(COMMON_DIR, "user-administrator.xml");
private static final String USER_ADMINISTRATOR_OID = SystemObjectsType.USER_ADMINISTRATOR.value();
private static final String USER_ADMINISTRATOR_USERNAME = "administrator";

private static final File ROLE_SUPERUSER_FILENAME = new File(COMMON_DIR, "role-superuser.xml");
private static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004";
public class TestOrgHierarchy extends AbstractLongTest {

//222 org. units, 2160 users
// private static final int[] TREE_LEVELS = {2, 5, 7, 2};
Expand All @@ -59,15 +49,6 @@ public class TestOrgHierarchy extends AbstractModelIntegrationTest {
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

// System Configuration and administrator
repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
modelService.postInit(initResult);

PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILENAME, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILENAME, initResult);
login(userAdministrator);

assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
}

Expand Down Expand Up @@ -123,7 +104,7 @@ private PrismObject<UserType> createUser(String parentOid, int i, int u, String
}

prismContext.adopt(user);
return user.asPrismContainer();
return user.asPrismObject();
}

private PrismObject<OrgType> createOrg(String parentOid, int i, String oidPrefix)
Expand All @@ -140,7 +121,7 @@ private PrismObject<OrgType> createOrg(String parentOid, int i, String oidPrefix
}

prismContext.adopt(org);
return org.asPrismContainer();
return org.asPrismObject();
}

private String createOid(int i, String oidPrefix) {
Expand Down

0 comments on commit 8169487

Please sign in to comment.