Search in sources :

Example 26 with ObjectModificationType

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);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 27 with ObjectModificationType

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);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 28 with ObjectModificationType

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;
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 29 with ObjectModificationType

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);
    }
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) ROrgClosure(com.evolveum.midpoint.repo.sql.data.common.ROrgClosure) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 30 with ObjectModificationType

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);
    }
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) ROrgClosure(com.evolveum.midpoint.repo.sql.data.common.ROrgClosure) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

ObjectModificationType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType)45 Test (org.testng.annotations.Test)40 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)31 File (java.io.File)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 Session (org.hibernate.Session)6 ROrgClosure (com.evolveum.midpoint.repo.sql.data.common.ROrgClosure)5 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)5 Entry (org.opends.server.types.Entry)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)3 QName (javax.xml.namespace.QName)3 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2