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 Aug 11, 2021
2 parents 647f737 + b408049 commit 049ea87
Show file tree
Hide file tree
Showing 27 changed files with 411 additions and 242 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -8,12 +8,21 @@

import static com.evolveum.midpoint.model.api.ModelPublicConstants.FOCUS_VALIDITY_SCAN_FULL_ID;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import org.testng.AssertJUnit;

import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
Expand All @@ -25,17 +34,10 @@
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.testng.AssertJUnit;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIntegrationTest {

Expand Down Expand Up @@ -248,10 +250,10 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIn
protected static final String ROLE_AUTOGRAPHIC_OID = "be835a70-e3f4-11e6-82cb-9b47ebe57b11";

protected static final File ROLE_AUTOTESTERS_FILE = new File(COMMON_DIR, "role-autotesters.xml");
protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v14";
protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57f14";

protected static final File ROLE_ADMINS_FILE = new File(COMMON_DIR, "role-admins.xml");
protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v15";
protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57f15";

protected static final File ROLE_END_USER_FILE = new File(COMMON_DIR, "role-end-user.xml");
protected static final String ROLE_END_USER_OID = "00000000-0000-0000-0000-00000000aa0f";
Expand All @@ -274,7 +276,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIn
protected static final String USER_BARBOSSA_USERNAME = "barbossa";
protected static final String USER_BARBOSSA_FULL_NAME = "Hector Barbossa";

protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml");
protected static final File USER_GUYBRUSH_FILE = new File(COMMON_DIR, "user-guybrush.xml");
protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116";
protected static final String USER_GUYBRUSH_USERNAME = "guybrush";
protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood";
Expand Down Expand Up @@ -319,7 +321,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIn

// Elaine has account on the dummy resources (default, red, blue)
// The accounts are also assigned
protected static final File USER_ELAINE_FILE = new File (COMMON_DIR, "user-elaine.xml");
protected static final File USER_ELAINE_FILE = new File(COMMON_DIR, "user-elaine.xml");
protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e";
protected static final String USER_ELAINE_USERNAME = "elaine";

Expand Down Expand Up @@ -352,7 +354,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIn
public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush";
public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood";
public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island";
public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml");
public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-guybrush-dummy.xml");
public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml");

public static final String ACCOUNT_SHADOW_JACK_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-jack-dummy.xml";
Expand Down Expand Up @@ -389,10 +391,10 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractEmptyModelIn

public static final String DUMMY_ORG_TOP_NAME = DummyResourceContoller.ORG_TOP_NAME;

protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml");
protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml");
protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003";

protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml");
protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml");
protected static final String PASSWORD_POLICY_BENEVOLENT_OID = "ed8026dc-569a-11e7-abdf-4fce56706755";

protected static final File ORG_MONKEY_ISLAND_FILE = new File(COMMON_DIR, "org-monkey-island.xml");
Expand Down Expand Up @@ -593,10 +595,10 @@ protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundExce
OperationResult result = createOperationResult("clearUserOrgAndRoleRefs");
Collection modifications = new ArrayList<>();
ReferenceDelta parentOrgRefDelta = prismContext.deltaFactory().reference().createModificationReplace(
UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue)null);
UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue) null);
modifications.add(parentOrgRefDelta);
ReferenceDelta roleMembershipRefDelta = prismContext.deltaFactory().reference().createModificationReplace(
UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue)null);
UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue) null);
modifications.add(roleMembershipRefDelta);
repositoryService.modifyObject(UserType.class, userOid, modifications, result);
result.computeStatus();
Expand All @@ -607,12 +609,12 @@ protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundExce

protected void assertEvaluatedRole(Collection<? extends EvaluatedAssignmentTarget> evaluatedRoles,
String expectedRoleOid) {
for (EvaluatedAssignmentTarget evalRole: evaluatedRoles) {
for (EvaluatedAssignmentTarget evalRole : evaluatedRoles) {
if (expectedRoleOid.equals(evalRole.getTarget().getOid())) {
return;
}
}
AssertJUnit.fail("Role "+expectedRoleOid+" no present in evaluated roles "+evaluatedRoles);
AssertJUnit.fail("Role " + expectedRoleOid + " no present in evaluated roles " + evaluatedRoles);
}

protected void assertSingleAccountPasswordNotification(String dummyResourceName, String username,
Expand Down Expand Up @@ -655,11 +657,11 @@ protected void assertSingleAccountPasswordNotificationGenerated(String dummyReso
String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0);
String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username);
if (!body.startsWith(expectedPrefix)) {
fail("Expected that "+dummyResourceName+" dummy password notification message starts with prefix '"+expectedPrefix+"', but it was: "+body);
fail("Expected that " + dummyResourceName + " dummy password notification message starts with prefix '" + expectedPrefix + "', but it was: " + body);
}
String suffix = body.substring(expectedPrefix.length());
if (suffix.isEmpty()) {
fail("Empty password in "+dummyResourceName+" dummy password notification message");
fail("Empty password in " + dummyResourceName + " dummy password notification message");
}
}

Expand All @@ -670,15 +672,15 @@ protected String getExpectedAccountPasswordNotificationBody(String dummyResource

protected String getExpectedAccountPasswordNotificationBodyPrefix(String dummyResourceName, String username) {
String resourceName = getDummyResourceType(dummyResourceName).getName().getOrig();
return "Password for account "+username+" on "+resourceName+" is: ";
return "Password for account " + username + " on " + resourceName + " is: ";
}

protected String getExpectedUserPasswordNotificationBody(String username, String password) {
return getExpectedUserPasswordNotificationBodyPrefix(username) + password;
}

protected String getExpectedUserPasswordNotificationBodyPrefix(String username) {
return "Password for user "+username+" is: ";
return "Password for user " + username + " is: ";
}

protected void displayAccountPasswordNotifications() {
Expand All @@ -693,7 +695,8 @@ protected Object getQuote(String description, String fullName) {
return description + " -- " + fullName;
}

protected void loginAdministrator() throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
protected void loginAdministrator() throws SchemaException, CommunicationException,
ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
login(userAdministrator);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -53,7 +53,6 @@ public class TestConnectorDummyFake extends AbstractConfiguredModelIntegrationTe
private PrismObject<ResourceType> resourceDummy;
private PrismObject<ResourceType> resourceDummyFake;

private DummyResourceContoller dummyResourceCtl;
protected static DummyResource dummyResource;

@Override
Expand All @@ -66,7 +65,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
// will be used instead of test logging config
super.initSystem(initTask, initResult);

dummyResourceCtl = DummyResourceContoller.create(null, resourceDummy);
DummyResourceContoller dummyResourceCtl = DummyResourceContoller.create(null, resourceDummy);
dummyResourceCtl.extendSchemaPirate();
dummyResource = dummyResourceCtl.getDummyResource();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
/*
* Copyright (c) 2010-2017 Evolveum and contributors
* Copyright (C) 2010-2021 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;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;

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 com.evolveum.icf.dummy.resource.DummyAccount;
import com.evolveum.icf.dummy.resource.DummyResource;
import com.evolveum.icf.dummy.resource.DummySyncStyle;
Expand All @@ -19,29 +31,12 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
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.SynchronizationSituationType;
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.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* Tests for MID-2436 (volatile attributes).
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestVolatility extends AbstractInitializedModelIntegrationTest {

Expand Down Expand Up @@ -97,22 +92,20 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception {

@Test
public void test110AddDummyHrAccountMancomb() throws Exception {
// GIVEN
given();
// Preconditions
//assertUsers(5);

DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME);
account.setEnabled(true);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood");

/// WHEN
when();

getDummyResource(RESOURCE_DUMMY_HR_NAME).addAccount(account);

waitForSyncTaskNextRun();

// THEN
then();

PrismObject<ShadowType> accountMancombHr = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME,
Expand Down Expand Up @@ -211,7 +204,7 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception {

@Test
public void test200ModifyGuybrushAssignAccount() throws Exception {
// GIVEN
given();
Task task = getTestTask();
OperationResult result = task.getResult();

Expand All @@ -224,10 +217,8 @@ public void test200ModifyGuybrushAssignAccount() throws Exception {
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_VOLATILE_OID, null, true);
deltas.add(accountAssignmentUserDelta);

// WHEN
modelService.executeChanges(deltas, null, task, result);

// THEN
then();

PrismObject<UserType> userGuybrush = findUserByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
Expand Down Expand Up @@ -261,7 +252,7 @@ public void test200ModifyGuybrushAssignAccount() throws Exception {

@Test
public void test300AddLargo() throws Exception {
// GIVEN
given();
Task task = getTestTask();
OperationResult result = task.getResult();

Expand All @@ -273,10 +264,8 @@ public void test300AddLargo() throws Exception {
ObjectDelta<UserType> userDelta = DeltaFactory.Object.createAddDelta(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);

// WHEN
modelService.executeChanges(deltas, null, task, result);

// THEN
then();

PrismObject<UserType> userLargo = findUserByUsername(ACCOUNT_LARGO_DUMMY_USERNAME);
Expand Down Expand Up @@ -313,7 +302,7 @@ public void test300AddLargo() throws Exception {
*/
@Test
public void test400AddHerman() throws Exception {
// GIVEN
given();
Task task = getTestTask();
OperationResult result = task.getResult();

Expand All @@ -325,11 +314,9 @@ public void test400AddHerman() throws Exception {
userBefore.asObjectable().getOrganization().add(createPolyStringType("bar"));
display("User before", userBefore);

// WHEN
when();
addObject(userBefore, task, result);

// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
Expand All @@ -352,16 +339,14 @@ public void test400AddHerman() throws Exception {
*/
@Test
public void test402ModifyHermanMonster() throws Exception {
// GIVEN
given();
Task task = getTestTask();
OperationResult result = task.getResult();

// WHEN
when();
modifyUserAdd(USER_HERMAN_OID, UserType.F_ORGANIZATION, task, result,
createPolyString(DummyResource.VALUE_MONSTER));

// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
Expand All @@ -385,5 +370,4 @@ protected void importSyncTask() throws FileNotFoundException {
protected void waitForSyncTaskNextRun() throws Exception {
waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, false, 10000);
}

}

0 comments on commit 049ea87

Please sign in to comment.