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());
}
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());
}
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());
}
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;
// }
}
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());
}
Aggregations