Search in sources :

Example 96 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class TestSanity method test022ChangeUserPassword.

/**
     * We are going to change user's password. As the user has an account, the password change
     * should be also applied to the account (by schemaHandling).
     */
@Test
public void test022ChangeUserPassword() throws Exception {
    final String TEST_NAME = "test022ChangeUserPassword";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_PASSWORD_FILENAME, ObjectDeltaType.class);
    System.out.println("In modification: " + objectChange.getItemDelta().get(0).getValue().get(0));
    assertNoRepoCache();
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertUserPasswordChange("butUnd3dM4yT4lkAL0t", result);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 97 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class TestSanityLegacy method test500NotifyChangeCreateAccount.

@Test
public void test500NotifyChangeCreateAccount() throws Exception {
    //    	try{
    TestUtil.displayTestTile("test500NotifyChangeCreateAccount");
    Entry ldifEntry = openDJController.addEntryFromLdifFile(LDIF_ANGELIKA_FILENAME);
    display("Entry from LDIF", ldifEntry);
    List<Attribute> attributes = ldifEntry.getAttributes();
    //        for (Attribute a : attributes){
    //        	display("attr anem : ", a.getAttributeType().toString());
    //        }
    List<Attribute> attrs = ldifEntry.getAttribute("entryUUID");
    AttributeValue val = null;
    if (attrs == null) {
        for (Attribute a : attributes) {
            if (a.getName().equals("entryUUID")) {
                val = a.iterator().next();
            }
        }
    } else {
        val = attrs.get(0).iterator().next();
    }
    String icfUid = val.toString();
    ShadowType anglicaAccount = parseObjectType(new File(ACCOUNT_ANGELIKA_FILENAME), ShadowType.class);
    PrismProperty prop = anglicaAccount.asPrismObject().findOrCreateProperty(new ItemPath(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_UID));
    prop.setValue(new PrismPropertyValue(icfUid));
    anglicaAccount.setResourceRef(ObjectTypeUtil.createObjectRef(RESOURCE_OPENDJ_OID, ObjectTypes.RESOURCE));
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    //    	repositoryService.addObject(anglicaAccount.asPrismObject(), null, parentResult);
    display("Angelica shdow: ", anglicaAccount.asPrismObject().debugDump());
    //    	provisioningService.applyDefinition(anglicaAccount.asPrismObject(), parentResult);
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.ADD);
    //    	ObjectToAdd objToAdd = new ObjectToAdd();
    //    	objToAdd.setAny(anglicaAccount);
    delta.setObjectToAdd(anglicaAccount);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    //    	delta.setOid(anglicaAccount.getOid());
    changeDescription.setObjectDelta(delta);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    TaskType task = modelWeb.notifyChange(changeDescription);
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertSuccess(result);
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    ShadowType modelShadow = modelService.getObject(ShadowType.class, oid, null, taskManager.createTaskInstance(), result).asObjectable();
    assertAttributeNotNull(modelShadow, SchemaConstants.ICFS_UID);
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "uid", "angelika");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "givenName", "Angelika");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "sn", "Marley");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "cn", "Angelika Marley");
//        assertAttribute(modelShadow, resourceTypeOpenDjrepo, "displayName", "Jack Sparrow");
//        assertAttribute(modelShadow, resourceTypeOpenDjrepo, "l", "middle of nowhere");
//    	} catch (Exception ex){
//    		display("exception: ", ex);
//    		throw ex;
//    	}
}
Also used : IntegrationTestTools.getAttributeValue(com.evolveum.midpoint.test.IntegrationTestTools.getAttributeValue) IntegrationTestTools.assertAttribute(com.evolveum.midpoint.test.IntegrationTestTools.assertAttribute) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 98 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class TestSanity method test503NotifyChangeDeleteAccount.

@Test
public void test503NotifyChangeDeleteAccount() throws Exception {
    final String TEST_NAME = "test503NotifyChangeDeleteAccount";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.DELETE);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    delta.setOid(oid);
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    // WHEN
    TaskType task = modelWeb.notifyChange(changeDescription);
    // THEN
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertTrue(result.isAcceptable());
    PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
    display("User after", userAngelikaAfterSync);
    assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
    UserType userType = userAngelikaAfterSync.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", userType.getLinkRef());
    assertEquals("Expected no account ref in user", 0, userType.getLinkRef().size());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 99 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class TestSanity method test104AssignRoleJudge.

/**
     * Judge role excludes pirate role. This assignment should fail. 
     */
@Test
public void test104AssignRoleJudge() throws Exception {
    final String TEST_NAME = "test104AssignRoleJudge";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResultType result = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result);
    Holder<String> oidHolder = new Holder<String>();
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_JUDGE_FILENAME, ObjectDeltaType.class);
    try {
        // WHEN ObjectTypes.USER.getTypeQName(), 
        result = modifyObjectViaModelWS(objectChange);
        // THEN
        AssertJUnit.fail("Expected a failure after assigning conflicting roles but nothing happened and life goes on");
    } catch (FaultMessage f) {
    // This is expected
    // TODO: check if the fault is the right one
    }
    assertNoRepoCache();
    displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object remain unmodified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    repoResult.computeStatus();
    display("User (repository)", repoUser);
    List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
    assertEquals("Unexpected number or accountRefs", 1, accountRefs.size());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 100 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class TestSanity method test502NotifyChangeModifyAccountPassword.

@Test
public void test502NotifyChangeModifyAccountPassword() throws Exception {
    final String TEST_NAME = "test502NotifyChangeModifyAccountPassword";
    TestUtil.displayTestTile(TEST_NAME);
    PrismObject<UserType> userAngelika = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelika);
    UserType user = userAngelika.asObjectable();
    assertNotNull("User with the name angelika must have one link ref.", user.getLinkRef());
    assertEquals("Expected one account ref in user", 1, user.getLinkRef().size());
    String oid = user.getLinkRef().get(0).getOid();
    String newPassword = "newPassword";
    openDJController.modifyReplace("uid=" + ANGELIKA_NAME + "," + openDJController.getSuffixPeople(), "userPassword", newPassword);
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.MODIFY);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    ItemDeltaType passwordDelta = new ItemDeltaType();
    passwordDelta.setModificationType(ModificationTypeType.REPLACE);
    passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
    RawType passwordValue = new RawType(((PrismContextImpl) prismContext).getBeanMarshaller().marshall(ModelClientUtil.createProtectedString(newPassword)), prismContext);
    passwordDelta.getValue().add(passwordValue);
    delta.getItemDelta().add(passwordDelta);
    delta.setOid(oid);
    LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(passwordDelta));
    LOGGER.info("delta: {}", DebugUtil.dump(passwordDelta));
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    //    	changeDescription.setCurrentShadow(angelicaShadowType);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    // WHEN
    TaskType task = modelWeb.notifyChange(changeDescription);
    // THEN
    OperationResult result = OperationResult.createOperationResult(task.getResult());
    display(result);
    assertSuccess(result);
    PrismObject<UserType> userAngelikaAfterSync = findUserByUsername(ANGELIKA_NAME);
    assertNotNull("User with the name angelika must exist.", userAngelikaAfterSync);
    assertUserLdapPassword(userAngelikaAfterSync, newPassword);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)136 Test (org.testng.annotations.Test)55 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)53 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)50 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)47 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)47 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)42 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)41 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)37 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)29 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)16 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)14 QName (javax.xml.namespace.QName)14 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)12