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