Search in sources :

Example 1 with ResourceObjectShadowChangeDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType in project midpoint by Evolveum.

the class TestSanityLegacy method test503NotifyChangeDeleteAccount.

@Test
public void test503NotifyChangeDeleteAccount() throws Exception {
    TestUtil.displayTestTile("test503NotifyChangeDeleteAccount");
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    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);
    TaskType task = modelWeb.notifyChange(changeDescription);
    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);
    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());
//    	String oid = userType.getLinkRef().get(0).getOid();
//    	UserType userAfterSync = userAngelikaAfterSync.asObjectable();
//    	PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
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 2 with ResourceObjectShadowChangeDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType in project midpoint by Evolveum.

the class TestSanityLegacy method test501NotifyChangeModifyAccount.

@Test
public void test501NotifyChangeModifyAccount() throws Exception {
    TestUtil.displayTestTile("test501NotifyChangeModifyAccount");
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    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.MODIFY);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    ItemDeltaType mod1 = new ItemDeltaType();
    mod1.setModificationType(ModificationTypeType.REPLACE);
    ItemPathType path = new ItemPathType(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName")));
    mod1.setPath(path);
    RawType value = new RawType(new PrimitiveXNode<String>("newAngelika"), prismContext);
    //TODO: shouldn't it be JaxbElement<PolyString>? 
    //    	Element el = DOMUtil.createElement(DOMUtil.getDocument(), new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName"));
    //    	el.setTextContent("newAngelika");
    mod1.getValue().add(value);
    delta.getItemDelta().add(mod1);
    delta.setOid(oid);
    LOGGER.info("item delta: {}", SchemaDebugUtil.prettyPrint(mod1));
    LOGGER.info("delta: {}", DebugUtil.dump(mod1));
    changeDescription.setObjectDelta(delta);
    changeDescription.setOldShadowOid(oid);
    changeDescription.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
    TaskType task = modelWeb.notifyChange(changeDescription);
    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);
    UserType userAfterSync = userAngelikaAfterSync.asObjectable();
    PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) 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) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with ResourceObjectShadowChangeDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType in project midpoint by Evolveum.

the class TestSanityLegacy method test502NotifyChangeModifyAccountPassword.

@Test
public void test502NotifyChangeModifyAccountPassword() throws Exception {
    TestUtil.displayTestTile("test502NotifyChangeModifyAccountPassword");
    OperationResult parentResult = new OperationResult("test500notifyChange.addAngelicaAccount");
    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();
    //    	    	PrismObject<ShadowType> angelicaAcc = modelService.getObject(ShadowType.class, oid, null, taskManager.createTaskInstance(), parentResult);
    //    	    	ShadowType angelicaShadowType = angelicaAcc.asObjectable();
    String newPassword = "newPassword";
    //    	    	ProtectedStringType decrypted= ModelClientUtil.createProtectedString(newPassword);
    //    	    	protector.encrypt(decrypted);
    //    	    	angelicaShadowType.getCredentials().getPassword().setValue(decrypted);
    ResourceObjectShadowChangeDescriptionType changeDescription = new ResourceObjectShadowChangeDescriptionType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setChangeType(ChangeTypeType.MODIFY);
    delta.setObjectType(ShadowType.COMPLEX_TYPE);
    Document doc = DOMUtil.getDocument();
    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);
    //    	ItemDeltaType mod1 = new ItemDeltaType();
    //    	mod1.setModificationType(ModificationTypeType.REPLACE);
    //    	ModelClientUtil.createProtectedString(clearValue)
    //    	XPathHolder xpath = new XPathHolder(SchemaConstants.PATH_PASSWORD);
    //    	Element path = xpath.toElement(SchemaConstantsGenerated.NS_TYPES, "path");
    //    	mod1.setPath(path);
    //    	String newPassword = "newPassword";
    //    	ItemDeltaType.Value value = new ItemDeltaType.Value();
    //    	Document doc = DOMUtil.getDocument();
    //    	Element el = DOMUtil.createElement(doc, SchemaConstantsGenerated.C_VALUE);
    //    	Element passwdEl = DOMUtil.createElement(doc, new QName(SchemaConstants.NS_C, "clearValue"));
    //    	passwdEl.setTextContent(newPassword);
    //    	el.appendChild(passwdEl);
    //        value.getAny().add(el);
    //        mod1.setValue(value);
    //    	delta.getModification().add(mod1);
    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);
    TaskType task = modelWeb.notifyChange(changeDescription);
    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);
    assertPassword(userAngelikaAfterSync, newPassword);
//    	UserType userAfterSync = userAngelikaAfterSync.asObjectable();
//    	PrismAsserts.assertEqualsPolyString("wrong given name in user angelika", PrismTestUtil.createPolyStringType("newAngelika"), userAfterSync.getGivenName());
}
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) Document(org.w3c.dom.Document) 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)

Example 4 with ResourceObjectShadowChangeDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType 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 5 with ResourceObjectShadowChangeDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType 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)

Aggregations

ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)9 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)8 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 ResourceObjectShadowChangeDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType)8 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)8 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 Test (org.testng.annotations.Test)8 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)4 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 IntegrationTestTools.assertAttribute (com.evolveum.midpoint.test.IntegrationTestTools.assertAttribute)2 IntegrationTestTools.getAttributeValue (com.evolveum.midpoint.test.IntegrationTestTools.getAttributeValue)2 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)2 File (java.io.File)2 QName (javax.xml.namespace.QName)2 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1