Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed May 16, 2017
2 parents 2b9161d + a68c92b commit 7ae87c8
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 86 deletions.
3 changes: 2 additions & 1 deletion gui/admin-gui/src/test/resources/ctx-admin-gui-test-main.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2013 Evolveum
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@
default-lazy-init="true" default-autowire="byName">

<bean name="midpointConfiguration" class="com.evolveum.midpoint.init.StartupConfiguration" init-method="init">
<constructor-arg value="./target/midpoint-home" />
<constructor-arg value="config-test.xml" />
</bean>

Expand Down
Expand Up @@ -18,12 +18,13 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.util.CloneUtil;
import com.evolveum.midpoint.util.PrettyPrinter;

/**
* @author mederly
*/
public class ExpressionWrapper {
public class ExpressionWrapper implements Cloneable {

private QName elementName;
private Object expression;
Expand All @@ -41,6 +42,11 @@ public QName getElementName() {
public Object getExpression() {
return expression;
}

public ExpressionWrapper clone() {
Object expressionClone = CloneUtil.clone(expression);
return new ExpressionWrapper(elementName, expressionClone);
}

@Override
public String toString() {
Expand Down
Expand Up @@ -345,6 +345,9 @@ public PrismPropertyValue<T> clone() {
protected void copyValues(PrismPropertyValue clone) {
super.copyValues(clone);
clone.value = CloneUtil.clone(this.value);
if (this.expression != null) {
clone.expression = this.expression.clone();
}
clone.rawElement = this.rawElement;
}

Expand Down Expand Up @@ -652,6 +655,10 @@ public String toString() {
if (value != null) {
builder.append(value.getClass().getSimpleName()).append(":");
builder.append(PrettyPrinter.prettyPrint(value));
} else if (isRaw()) {
builder.append("[raw]");
} else if (expression != null) {
builder.append("[expression]");
} else {
builder.append("null");
}
Expand Down
Expand Up @@ -101,7 +101,7 @@ public static void searchClasses(String packageName, Consumer<Class> consumer) {
* destination
* @return successful extraction
*/
public static Boolean extractFileFromClassPath(String src, String dst) {
public static boolean extractFileFromClassPath(String src, String dst) {
InputStream is = ClassPathUtil.class.getClassLoader().getResourceAsStream(src);
if (null == is) {
LOGGER.error("Unable to find file {} for extraction to {}", src, dst);
Expand Down
Expand Up @@ -1078,4 +1078,6 @@ List<ObjectReferenceType> getMembersAsReferences(String orgOid)
String createPasswordResetLink(UserType userType);

String createAccountActivationLink(UserType userType);

String getConst(String name);
}
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.model.api.context.ModelElementContext;
import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision;
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.common.ConstantsManager;
import com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext;
import com.evolveum.midpoint.model.impl.ModelObjectResolver;
import com.evolveum.midpoint.model.impl.lens.LensContext;
Expand Down Expand Up @@ -123,6 +124,9 @@ public class MidpointFunctionsImpl implements MidpointFunctions {

@Autowired
private WorkflowService workflowService;

@Autowired
private ConstantsManager constantsManager;

public String hello(String name) {
return "Hello "+name;
Expand Down Expand Up @@ -1351,4 +1355,9 @@ private String getNonce(UserType user) {
return null;
}
}

@Override
public String getConst(String name) {
return constantsManager.getConstantValue(name);
}
}
Expand Up @@ -32,6 +32,7 @@
import com.evolveum.midpoint.schema.result.OperationResult;
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.MiscUtil;
import com.evolveum.midpoint.util.QNameUtil;
Expand Down Expand Up @@ -72,7 +73,7 @@
*
*/
public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest {

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

Expand Down Expand Up @@ -114,12 +115,14 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004";
protected static final String RESOURCE_DUMMY_DRINK = "rum";
protected static final String RESOURCE_DUMMY_QUOTE = "Arr!";
protected static final String RESOURCE_DUMMY_USELESS_STRING = "USEless";

// RED resource has STRONG mappings
protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml");
protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104";
protected static final String RESOURCE_DUMMY_RED_NAME = "red";
protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI;
protected static final String RESOURCE_DUMMY_RED_USELESS_STRING = IntegrationTestTools.CONST_USELESS;

// BLUE resource has WEAK mappings, outbound/inbound
protected static final File RESOURCE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "resource-dummy-blue.xml");
Expand Down
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down Expand Up @@ -88,6 +89,24 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
repoAddObjectFromFile(USER_GUYBRUSH_FILE, true, initResult);
repoAddObjectFromFile(USER_ELAINE_FILE, true, initResult);
}

@Test
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);

// WHEN
OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_YELLOW_OID, task);

// THEN
display("Test result", testResult);
assertSuccess(testResult);

assertEquals("Wrong YELLOW useless string", IntegrationTestTools.CONST_USELESS, dummyResourceYellow.getUselessString());
}

@Test
public void test100JackAssignDummyYellow() throws Exception {
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
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.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
Expand Down Expand Up @@ -1815,9 +1816,14 @@ public void test300AssignGuybrushDummyYellow() throws Exception {
ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
display("Dummy account", dummyAccount);
assertDummyAccountAttribute(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME,
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Bla bla bla administrator -- administrator");
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME,
IntegrationTestTools.CONST_DRINK);
assertDummyAccountAttribute(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME,
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME,
IntegrationTestTools.CONST_BLABLA + " administrator -- administrator");
assertDummyAccountAttribute(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME,
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "Some say elaine -- administrator");
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME,
"Some say elaine -- administrator");
}

@Test
Expand Down
Expand Up @@ -94,12 +94,10 @@ public class TestResources extends AbstractConfiguredModelIntegrationTest {

protected DummyResource dummyResource;
protected DummyResourceContoller dummyResourceCtl;
protected ResourceType resourceDummyType;
protected PrismObject<ResourceType> resourceDummy;

protected DummyResource dummyResourceRed;
protected DummyResourceContoller dummyResourceCtlRed;
protected ResourceType resourceDummyRedType;
protected PrismObject<ResourceType> resourceDummyRed;

@Override
Expand All @@ -118,7 +116,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
resourceDummy.asObjectable().getConnectorRef().setOid(connectorDummy.getOid());
repositoryService.addObject(resourceDummy, null, initResult);

resourceDummyType = resourceDummy.asObjectable();
dummyResourceCtl.setResource(resourceDummy);


Expand All @@ -131,10 +128,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
resourceDummyRed.asObjectable().getConnectorRef().setOid(connectorDummy.getOid());
repositoryService.addObject(resourceDummyRed, null, initResult);

resourceDummyRedType = resourceDummyRed.asObjectable();
dummyResourceCtlRed.setResource(resourceDummyRed);



ResourceCarefulAntUtil.initAnts(ants, RESOURCE_DUMMY_FILE, prismContext);
descriptionAnt = ants.get(0);
InternalMonitor.reset();
Expand Down Expand Up @@ -521,6 +516,8 @@ public void test110GetResourceDummy() throws Exception {
assertConnectorSchemaParseIncrement(0);

IntegrationTestTools.displayXml("Initialized dummy resource", resource);

assertEquals("Wrong dummy useless string", RESOURCE_DUMMY_USELESS_STRING, dummyResource.getUselessString());
}

@Test
Expand Down Expand Up @@ -747,6 +744,44 @@ public void test200GetResourceRawAfterSchema() throws Exception {
IntegrationTestTools.displayXml("Initialized dummy resource", resource);
}

/**
* Red resource has an expression for uselessString configuration property. Check that.
*/
@Test
public void test210GetResourceDummyRed() throws Exception {
final String TEST_NAME = "test210GetResourceDummyRed";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);

rememberPrismObjectCloneCount();

// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_RED_OID, null , task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
assertSuccess(result);

assertPrismObjectCloneIncrement(1);

assertResourceDummy(resource, true);

assertResourceSchemaFetchIncrement(0);
assertResourceSchemaParseCountIncrement(0);
assertConnectorCapabilitiesFetchIncrement(0);
assertConnectorInitializationCountIncrement(0);
assertConnectorSchemaParseIncrement(0);

IntegrationTestTools.displayXml("Initialized dummy resource", resource);

assertEquals("Wrong RED useless string", RESOURCE_DUMMY_RED_USELESS_STRING, dummyResourceRed.getUselessString());
}

@Test
public void test750GetResourceRaw() throws Exception {
final String TEST_NAME = "test750GetResourceRaw";
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2016 Evolveum
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<name>Dummy Resource Red</name>

<connectorRef type="ConnectorType">
<filter>
<q:and>
Expand All @@ -43,11 +44,17 @@
</q:and>
</filter>
</connectorRef>

<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">

<icfc:configurationProperties>
<icfi:instanceId>red</icfi:instanceId>
<icfi:uselessString>
<expression>
<const>useless</const>
</expression>
</icfi:uselessString>
</icfc:configurationProperties>

</connectorConfiguration>
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2016 Evolveum
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,8 @@

<!-- yellow resource - almost same as resource-dummy but with strong asIs administrativeStatus mapping
also has a modified synchronization section: just correlation but no reactions.
also it has minimum password length constraint. -->
also it has minimum password length constraint
also it is using some constants in the configuration and expressions. -->

<resource oid="10000000-0000-0000-0000-000000000704"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
Expand Down Expand Up @@ -51,6 +52,11 @@
<icfc:configurationProperties>
<icfi:instanceId>yellow</icfi:instanceId>
<icfi:requireExplicitEnable>true</icfi:requireExplicitEnable>
<icfi:uselessString>
<expression>
<const>useless</const>
</expression>
</icfi:uselessString>
<icfi:uselessGuardedString>
<clearValue>whatever</clearValue>
</icfi:uselessGuardedString>
Expand Down Expand Up @@ -187,7 +193,7 @@
<outbound>
<strength>strong</strength>
<expression>
<value>rum</value>
<const>drink</const>
</expression>
</outbound>
</attribute>
Expand All @@ -200,7 +206,7 @@
<expression>
<script>
<code>
'Bla bla bla ' + midpoint.getPrincipal().getUsername() + ' -- ' + actor?.getName()
midpoint.getConst('blabla') + ' ' + midpoint.getPrincipal().getUsername() + ' -- ' + actor?.getName()
</code>
</script>
</expression>
Expand Down
6 changes: 3 additions & 3 deletions model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -76,7 +76,7 @@
<logger name="com.evolveum.midpoint.model.impl.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="TRACE" />
<logger name="com.evolveum.midpoint.provisioning" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ResourceManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.consistency" level="DEBUG" />
<logger name="com.evolveum.midpoint.expression" level="DEBUG" />
Expand All @@ -89,8 +89,8 @@
<logger name="com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyGenerator" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.controller.ObjectMerger" level="DEBUG" />
<logger name="com.evolveum.midpoint.notifications" level="DEBUG" />
<logger name="com.evolveum.midpoint.security" level="TRACE" />
<logger name="com.evolveum.midpoint.security.impl.SecurityEnforcerImpl" level="TRACE" />
<logger name="com.evolveum.midpoint.security" level="DEBUG" />
<logger name="com.evolveum.midpoint.security.impl.SecurityEnforcerImpl" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.security" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.util.AbstractSearchIterativeTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.SynchronizationServiceImpl" level="DEBUG" />
Expand Down
Expand Up @@ -117,10 +117,6 @@ public class TestUcfOpenDj extends AbstractTestNGSpringContextTests {

protected static OpenDJController openDJController = new OpenDJController();

public TestUcfOpenDj() {
System.setProperty("midpoint.home", "target/midPointHome/");
}

@BeforeSuite
public void setup() throws SchemaException, SAXException, IOException {
PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX);
Expand Down

0 comments on commit 7ae87c8

Please sign in to comment.