use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class TestOpenDjNegative method test550ModifyObject.
@Test
public void test550ModifyObject() throws Exception {
final String TEST_NAME = "test150ModifyObject";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext());
display("Object change", delta);
Task task = taskManager.createTaskInstance();
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result);
// THEN
result.computeStatus();
display("deleteObject result", result);
assertEquals("Wrong result", OperationResultStatus.HANDLED_ERROR, result.getStatus());
ShadowType repoAccountType = repositoryService.getObject(ShadowType.class, ACCOUNT_JACK_OID, null, result).asObjectable();
display("repo shadow", repoAccountType);
assertEquals("Wrong failedOperationType in repo", FailedOperationTypeType.MODIFY, repoAccountType.getFailedOperationType());
OperationResultType repoResult = repoAccountType.getResult();
assertNotNull("No result in shadow (repo)", repoResult);
TestUtil.assertFailure("Result in shadow (repo)", repoResult);
ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_JACK_OID, null, task, result).asObjectable();
display("provisioning shadow", provisioningAccountType);
assertEquals("Wrong failedOperationType in repo", FailedOperationTypeType.MODIFY, provisioningAccountType.getFailedOperationType());
OperationResultType provisioningResult = provisioningAccountType.getResult();
assertNotNull("No result in shadow (repo)", provisioningResult);
TestUtil.assertFailure("Result in shadow (repo)", provisioningResult);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class TestOpenDj method test150ChangePassword.
@Test
public void test150ChangePassword() throws Exception {
final String TEST_NAME = "test150ChangePassword";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_MODIFY_PASSWORD_FILE, ShadowType.class);
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
assertEquals(ACCOUNT_MODIFY_PASSWORD_OID, addedObjectOid);
ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_MODIFY_PASSWORD_OID, null, taskManager.createTaskInstance(), result).asObjectable();
display("Object before password change", accountType);
String uid = null;
uid = ShadowUtil.getSingleStringAttributeValue(accountType, getPrimaryIdentifierQName());
assertNotNull(uid);
Entry entryBefore = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account before", entryBefore);
String passwordBefore = OpenDJController.getAttributeValue(entryBefore, "userPassword");
assertNull("Unexpected password before change", passwordBefore);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "account-change-password.xml"), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, accountType.asPrismObject().getDefinition());
display("Object change", delta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
// Check if object was modified in LDAP
Entry entryAfter = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account after", entryAfter);
String passwordAfter = OpenDJController.getAttributeValue(entryAfter, "userPassword");
assertNotNull("The password was not changed", passwordAfter);
System.out.println("Changed password: " + passwordAfter);
openDJController.assertPassword(entryAfter.getDN().toString(), "mehAbigH4X0R");
assertShadows(4);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class UserPhotoTest method parseDelta.
protected ObjectDelta<UserType> parseDelta(String oid, File file) throws SchemaException, IOException {
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<UserType> delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
delta.setOid(oid);
return delta;
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class OrgStructTest method test004modifyOrgStructAddUser.
// users are not in the closure any more
@Test(enabled = false)
public void test004modifyOrgStructAddUser() throws Exception {
Session session = open();
try {
OperationResult opResult = new OperationResult("test004modifyOrgStructAddUser");
//test modification of org ref in another org type..
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_ADD_USER_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<UserType> delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
repositoryService.modifyObject(UserType.class, ELAINE_OID, delta.getModifications(), opResult);
LOGGER.info("==>after modify - add user to org<==");
List<ROrgClosure> orgClosure = getOrgClosureByDescendant(ELAINE_OID, session);
AssertJUnit.assertEquals(7, orgClosure.size());
LOGGER.info("==============CLOSURE TABLE==========");
for (ROrgClosure o : orgClosure) {
LOGGER.info("=> A: {}, D: {}", o.getAncestor(), o.getDescendant());
}
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class OrgStructTest method test003modifyOrgStructDeleteRefIncorrect.
@Test
public void test003modifyOrgStructDeleteRefIncorrect() throws Exception {
// test modification of org ref - delete org ref
OperationResult opResult = new OperationResult("test003modifyOrgStructDeleteRefIncorrect");
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_INCORRECT_DELETE_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
Session session = open();
try {
LOGGER.info("==>before modify - delete<==");
List<ROrgClosure> orgClosure = getOrgClosure(ORG_F012_OID, MODIFY_ORG_INCORRECT_DELETE_REF_OID, session);
AssertJUnit.assertEquals(0, orgClosure.size());
session.getTransaction().commit();
repositoryService.modifyObject(OrgType.class, MODIFY_ORG_INCORRECT_DELETE_REF_OID, delta.getModifications(), opResult);
session.clear();
session.beginTransaction();
LOGGER.info("==>after modify - delete<==");
orgClosure = getOrgClosure(ORG_F012_OID, MODIFY_ORG_INCORRECT_DELETE_REF_OID, session);
AssertJUnit.assertEquals(0, orgClosure.size());
} finally {
close(session);
}
}
Aggregations