Skip to content

Commit

Permalink
Fixed failing integration test because of missing initial objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Feb 27, 2023
1 parent 7b82f7b commit 05e72b0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.TestObject;
import com.evolveum.midpoint.test.asserter.DummyAccountAsserter;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MarkType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;

/**
* @author semancik
Expand Down Expand Up @@ -146,6 +150,14 @@ public abstract class AbstractDummyTest extends AbstractProvisioningIntegrationT

protected String accountWillCurrentPassword = ACCOUNT_WILL_PASSWORD;

protected static final TestObject<ArchetypeType> ARCHETYPE_OBJECT_MARK = TestObject.classPath(
"initial-objects/archetype", "701-archetype-object-mark.xml", SystemObjectsType.ARCHETYPE_OBJECT_MARK.value());


protected static final TestObject<MarkType> MARK_PROTECTED_SHADOW = TestObject.classPath(
"initial-objects/mark", "750-mark-protected-shadow.xml",
SystemObjectsType.MARK_PROTECTED_SHADOW.value());

@Autowired
protected ProvisioningContextFactory provisioningContextFactory;

Expand Down Expand Up @@ -182,6 +194,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
setIcfUid(shadowDaemon, dummyAccountDaemon.getId());
}
repositoryService.addObject(shadowDaemon, null, initResult);

if(areMarksSupported()) {
repoAdd(ARCHETYPE_OBJECT_MARK, initResult);
repoAdd(MARK_PROTECTED_SHADOW, initResult);
}
}

protected String getDummyConnectorType() {
Expand All @@ -205,6 +222,7 @@ protected String getIcfUid(ShadowType shadowType) {
return getIcfUid(shadowType.asPrismObject());
}

@Override
protected String getIcfUid(PrismObject<ShadowType> shadow) {
PrismProperty<String> icfUidAttr = shadow.findProperty(SchemaConstants.ICFS_UID_PATH);
return icfUidAttr.getRealValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ protected ItemComparisonResult getExpectedPasswordComparisonResultMismatch() {
return ItemComparisonResult.NOT_APPLICABLE;
}

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
if (areMarksSupported()) {
repoAdd(ARCHETYPE_SHADOW_MARK, initResult);
repoAdd(TAG_PROTECTED_SHADOW, initResult);
}
}

// test000-test100 in the superclasses


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,26 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.AbstractIntegrationTest;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.TestObject;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MarkType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;

@ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml")
@DirtiesContext
public class TestSynchronization extends AbstractIntegrationTest {

protected static final TestObject<ArchetypeType> ARCHETYPE_OBJECT_MARK = TestObject.classPath(
"initial-objects/archetype", "701-archetype-object-mark.xml", SystemObjectsType.ARCHETYPE_OBJECT_MARK.value());


protected static final TestObject<MarkType> MARK_PROTECTED_SHADOW = TestObject.classPath(
"initial-objects/mark", "750-mark-protected-shadow.xml",
SystemObjectsType.MARK_PROTECTED_SHADOW.value());

private static final File TEST_DIR = new File("src/test/resources/synchronization/");

private static final File RESOURCE_OPENDJ_FILE = AbstractOpenDjTest.RESOURCE_OPENDJ_FILE;
Expand Down Expand Up @@ -87,6 +99,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti

//it is needed to declare the task owner, so we add the user admin to the reposiotry
repoAddObjectFromFile(ProvisioningTestUtil.USER_ADMIN_FILE, initResult);
if(areMarksSupported()) {
repoAdd(ARCHETYPE_OBJECT_MARK, initResult);
repoAdd(MARK_PROTECTED_SHADOW, initResult);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected boolean isProtectedByResourcePolicy(ShadowType shadow, Collection<Obje

@Override
protected boolean policyNotExcluded(ObjectType shadow, String markOid) {
return containsPolicyStatement(shadow, markOid, EXCLUDE);
return !containsPolicyStatement(shadow, markOid, EXCLUDE);
}

protected boolean containsPolicyStatement(@NotNull ObjectType shadow, @NotNull String markOid, @NotNull PolicyStatementTypeType policyType) {
Expand Down

0 comments on commit 05e72b0

Please sign in to comment.