use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ConsistencyTest method test130DeleteObjectNotFound.
@Test
public void test130DeleteObjectNotFound() throws Exception {
final String TEST_NAME = "test130DeleteObjectNotFound";
TestUtil.displayTestTile(TEST_NAME);
OperationResult parentResult = new OperationResult(TEST_NAME);
repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, parentResult);
repoAddObjectFromFile(USER_GUYBRUSH_FILENAME, parentResult);
Task task = taskManager.createTaskInstance();
requestToExecuteChanges(REQUEST_USER_MODIFY_DELETE_ACCOUNT, USER_GUYBRUSH_OID, UserType.class, task, null, parentResult);
// WHEN
ObjectDelta deleteDelta = ObjectDelta.createDeleteDelta(ShadowType.class, ACCOUNT_GUYBRUSH_OID, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(deleteDelta);
modelService.executeChanges(deltas, null, task, parentResult);
try {
repositoryService.getObject(ShadowType.class, ACCOUNT_GUYBRUSH_OID, null, parentResult);
} catch (Exception ex) {
if (!(ex instanceof ObjectNotFoundException)) {
fail("Expected ObjectNotFoundException but got " + ex);
}
}
assertUserNoAccountRef(USER_GUYBRUSH_OID, parentResult);
repositoryService.deleteObject(UserType.class, USER_GUYBRUSH_OID, parentResult);
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ConsistencyTest method test220DeleteObjectCommunicationProblem.
@Test
public void test220DeleteObjectCommunicationProblem() throws Exception {
final String TEST_NAME = "test220DeleteObjectCommunicationProblem";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
openDJController.assumeStopped();
Task task = taskManager.createTaskInstance(TEST_NAME);
OperationResult parentResult = task.getResult();
String accountOid = assertUserOneAccountRef(USER_DENIELS_OID);
//WHEN
requestToExecuteChanges(REQUEST_USER_MODIFY_DELETE_ACCOUNT_COMMUNICATION_PROBLEM, USER_DENIELS_OID, UserType.class, task, null, parentResult);
assertUserNoAccountRef(USER_DENIELS_OID, parentResult);
ObjectDelta deleteDelta = ObjectDelta.createDeleteDelta(ShadowType.class, ACCOUNT_DENIELS_OID, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(deleteDelta);
modelService.executeChanges(deltas, null, task, parentResult);
// THEN
checkPostponedAccountBasic(accountOid, FailedOperationTypeType.DELETE, false, parentResult);
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ConsistencyTest method createDeltas.
private Collection<ObjectDelta<? extends ObjectType>> createDeltas(Class type, String requestFilename, String objectOid) throws IOException, SchemaException, JAXBException {
try {
ObjectDeltaType objectChange = unmarshallValueFromFile(requestFilename, ObjectDeltaType.class);
objectChange.setOid(objectOid);
ObjectDelta delta = DeltaConvertor.createObjectDelta(objectChange, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(delta);
return deltas;
} catch (Exception ex) {
LOGGER.error("ERROR while unmarshalling: {}", ex);
throw ex;
}
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ConsistencyTest method test283GetObjectNoFetchShadowAndRecompute.
@Test
public void test283GetObjectNoFetchShadowAndRecompute() throws Exception {
final String TEST_NAME = "test283GetObjectNoFetchShadowAndRecompute";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
openDJController.assumeRunning();
OperationResult parentResult = new OperationResult(TEST_NAME);
String accountOid = assertUserOneAccountRef(USER_DONALD_OID);
Task task = taskManager.createTaskInstance();
// Get user's account with noFetch option - changes shouldn't be applied, bud should be still saved in shadow
PrismObject<ShadowType> johnAccount = modelService.getObject(ShadowType.class, accountOid, GetOperationOptions.createNoFetchCollection(), task, parentResult);
ShadowType johnAccountType = checkPostponedAccountBasic(johnAccount, FailedOperationTypeType.MODIFY, true, parentResult);
ObjectDelta deltaInAccount = DeltaConvertor.createObjectDelta(johnAccountType.getObjectChange(), prismContext);
assertTrue("Delta stored in account must contain given name modification", deltaInAccount.hasItemDelta(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "givenName"))));
assertFalse("Delta stored in account must not contain employeeType modification", deltaInAccount.hasItemDelta(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "employeeType"))));
assertNotNull("Donald's account must contain reference on the resource", johnAccountType.getResourceRef());
//THEN recompute the user - postponed changes should be applied
LOGGER.info("recompute user - account with weak mapping after stopping opendj.");
ObjectDelta<UserType> emptyDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_DONALD_OID, prismContext);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
deltas.add(emptyDelta);
modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, parentResult);
accountOid = assertUserOneAccountRef(USER_DONALD_OID);
johnAccountType = checkNormalizedShadowWithAttributes(accountOid, "donald", "don", "trump", "donald trump", false, task, parentResult);
//TODO: check on user if it was processed successfully (add this check also to previous (30) test..
}
use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.
the class ConsistencyTest method test500AddUserMorganWithAssignment.
/**
* Adding a user (morgan) that has an OpenDJ assignment. But the equivalent account already exists on
* OpenDJ. The account should be linked.
*/
@Test
public void test500AddUserMorganWithAssignment() throws Exception {
final String TEST_NAME = "test500AddUserMorganWithAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
openDJController.assumeRunning();
Task task = taskManager.createTaskInstance(ConsistencyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
Entry entry = openDJController.addEntryFromLdifFile(LDIF_MORGAN_FILENAME);
display("Entry from LDIF", entry);
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(USER_MORGAN_FILENAME));
display("Adding user", user);
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
// assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus());
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userMorganType.getLinkRef().size());
ObjectReferenceType accountRefType = userMorganType.getLinkRef().get(0);
String accountOid = accountRefType.getOid();
assertFalse("No accountRef oid", StringUtils.isBlank(accountOid));
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
assertShadowRepo(accountShadow, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertShadowModel(accountModel, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// TODO: check OpenDJ Account
}
Aggregations