use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class TestSanityLegacy method test020ModifyUser.
/**
* We are going to modify the user. As the user has an account, the user
* changes should be also applied to the account (by schemaHandling).
*/
@Test
public void test020ModifyUser() throws Exception {
final String TEST_NAME = "test020ModifyUser";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
assertNoRepoCache();
ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_FULLNAME_LOCALITY_FILENAME, ObjectDeltaType.class);
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(objectChange);
// THEN
assertNoRepoCache();
displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("modifyObject has failed", result);
// Check if user object was modified in the repo
OperationResult repoResult = new OperationResult("getObject");
PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
UserType repoUserType = repoUser.asObjectable();
display("repository user", repoUser);
PrismAsserts.assertEqualsPolyString("wrong value for fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
PrismAsserts.assertEqualsPolyString("wrong value for locality", "somewhere", repoUserType.getLocality());
assertEquals("wrong value for employeeNumber", "1", repoUserType.getEmployeeNumber());
// Check if appropriate accountRef is still there
List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
assertEquals(1, accountRefs.size());
for (ObjectReferenceType accountRef : accountRefs) {
assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj));
}
// Check if shadow is still in the repo and that it is untouched
repoResult = new OperationResult("getObject");
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
repoResult.computeStatus();
TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
display("repository shadow", repoShadow);
AssertJUnit.assertNotNull(repoShadow);
ShadowType repoShadowType = repoShadow.asObjectable();
AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
// check attributes in the shadow: should be only identifiers (ICF UID)
String uid = checkRepoShadow(repoShadow);
// Check if LDAP account was updated
assertOpenDJAccountJack(uid, "jack");
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class TestSanity method test102AssignRoleCaptain.
@Test
public void test102AssignRoleCaptain() throws Exception {
final String TEST_NAME = "test102AssignRoleCaptain";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_1_FILENAME, ObjectDeltaType.class);
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(objectChange);
// THEN
assertNoRepoCache();
displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("modifyObject has failed", result);
// Check if user object was modified 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(1, accountRefs.size());
ObjectReferenceType accountRef = accountRefs.get(0);
assertEquals(accountShadowOidGuybrushOpendj, accountRef.getOid());
// Check if shadow is still in the repo
repoResult = new OperationResult("getObject");
PrismObject<ShadowType> aObject = repositoryService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, repoResult);
ShadowType repoShadow = aObject.asObjectable();
repoResult.computeStatus();
TestUtil.assertSuccess("getObject has failed", repoResult);
display("Shadow (repository)", repoShadow);
assertNotNull(repoShadow);
assertEquals(RESOURCE_OPENDJ_OID, repoShadow.getResourceRef().getOid());
// check if account is still in LDAP
Entry entry = openDJController.searchAndAssertByEntryUuid(accountGuybrushOpendjEntryUuuid);
display("LDAP account", entry);
OpenDJController.assertAttribute(entry, "uid", "guybrush");
OpenDJController.assertAttribute(entry, "givenName", "Guybrush");
OpenDJController.assertAttribute(entry, "sn", "Threepwood");
OpenDJController.assertAttribute(entry, "cn", "Guybrush Threepwood");
OpenDJController.assertAttribute(entry, "displayName", "Guybrush Threepwood");
// The "l" attribute is assigned indirectly through schemaHandling and
// config object
OpenDJController.assertAttribute(entry, "l", "Deep in the Caribbean");
// Set by the role
OpenDJController.assertAttribute(entry, "employeeType", "sailor");
OpenDJController.assertAttribute(entry, "title", "Bloody Pirate", "Honorable Captain");
OpenDJController.assertAttribute(entry, "carLicense", "C4PT41N");
OpenDJController.assertAttribute(entry, "businessCategory", "loot", "murder", "cruise");
// Expression in the role taking that from the user
OpenDJController.assertAttribute(entry, "destinationIndicator", "Guybrush Threepwood");
OpenDJController.assertAttribute(entry, "departmentNumber", "Department of Guybrush");
// Expression in the role taking that from the assignment
OpenDJController.assertAttribute(entry, "physicalDeliveryOfficeName", "The Sea Monkey");
String guybrushPassword = OpenDJController.getAttributeValue(entry, "userPassword");
assertNotNull("Pasword disappeared", guybrushPassword);
// TODO: Derby
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class TestSanity method test109UnassignRoleCaptainAgain.
/**
* Captain role was assigned twice. It has to also be unassigned twice.
*/
@Test
public void test109UnassignRoleCaptainAgain() throws Exception {
final String TEST_NAME = "test109UnassignRoleCaptainAgain";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResultType result = new OperationResultType();
assertNoRepoCache();
ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_DELETE_ROLE_CAPTAIN_2_FILENAME, ObjectDeltaType.class);
// WHEN ObjectTypes.USER.getTypeQName(),
result = modifyObjectViaModelWS(objectChange);
// THEN
assertNoRepoCache();
displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
//TODO TODO TODO TODO operation result from repostiory.getObject is unknown...find out why..
// assertSuccess("modifyObject has failed", result);
// Check if user object was modified in the repo
OperationResult repoResult = new OperationResult("getObject");
PropertyReferenceListType resolve = new PropertyReferenceListType();
PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
UserType repoUserType = repoUser.asObjectable();
repoResult.computeStatus();
display("User (repository)", repoUserType);
List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
assertEquals(0, accountRefs.size());
// Check if shadow was deleted from the repo
repoResult = new OperationResult("getObject");
try {
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, repoResult);
AssertJUnit.fail("Account shadow was not deleted from repo");
} catch (ObjectNotFoundException ex) {
// This is expected
}
// check if account was deleted from LDAP
Entry entry = openDJController.searchByEntryUuid(accountGuybrushOpendjEntryUuuid);
display("LDAP account", entry);
assertNull("LDAP account was not deleted", entry);
// TODO: Derby
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class TestSanity method test040UnlinkDerbyAccountFromUser.
/**
* Unlink account by removing the accountRef from the user.
* The account will not be deleted, just the association to user will be broken.
*/
@Test
public void test040UnlinkDerbyAccountFromUser() throws FileNotFoundException, JAXBException, FaultMessage, ObjectNotFoundException, SchemaException, DirectoryException, SQLException {
TestUtil.displayTestTile("test040UnlinkDerbyAccountFromUser");
// GIVEN
ObjectDeltaType objectChange = new ObjectDeltaType();
objectChange.setOid(USER_JACK_OID);
ItemDeltaType modificationDeleteAccountRef = new ItemDeltaType();
modificationDeleteAccountRef.setModificationType(ModificationTypeType.DELETE);
ObjectReferenceType accountRefToDelete = new ObjectReferenceType();
accountRefToDelete.setOid(accountShadowOidDerby);
RawType modificationValue = new RawType(((PrismContextImpl) prismContext).getBeanMarshaller().marshall(accountRefToDelete), prismContext);
modificationDeleteAccountRef.getValue().add(modificationValue);
modificationDeleteAccountRef.setPath(new ItemPathType(new ItemPath(UserType.F_LINK_REF)));
objectChange.getItemDelta().add(modificationDeleteAccountRef);
objectChange.setChangeType(ChangeTypeType.MODIFY);
objectChange.setObjectType(UserType.COMPLEX_TYPE);
displayJaxb("modifyObject input", objectChange, new QName(SchemaConstants.NS_C, "change"));
assertNoRepoCache();
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(objectChange);
// THEN
assertNoRepoCache();
displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("modifyObject has failed", result);
// Check if user object was modified in the repo
OperationResult repoResult = new OperationResult("getObject");
PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
UserType repoUser = uObject.asObjectable();
repoResult.computeStatus();
display("User (repository)", repoUser);
List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
// only OpenDJ account should be left now
assertEquals(1, accountRefs.size());
ObjectReferenceType ref = accountRefs.get(0);
assertEquals("Wrong OID in accountRef in " + repoUser, accountShadowOidOpendj, ref.getOid());
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class TestSanity method test014AddDerbyAccountToUser.
/**
* Add Derby account to user. This should result in account provisioning. Check if
* that happens in repo and in Derby.
*/
@Test
public void test014AddDerbyAccountToUser() throws IOException, JAXBException, FaultMessage, ObjectNotFoundException, SchemaException, DirectoryException, SQLException {
TestUtil.displayTestTile("test014AddDerbyAccountToUser");
// GIVEN
checkRepoDerbyResource();
assertNoRepoCache();
ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ACCOUNT_DERBY_FILENAME, ObjectDeltaType.class);
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(objectChange);
// THEN
assertNoRepoCache();
displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("modifyObject has failed", result);
// Check if user object was modified in the repo
OperationResult repoResult = new OperationResult("getObject");
PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
UserType repoUser = uObject.asObjectable();
repoResult.computeStatus();
display("User (repository)", repoUser);
List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
// OpenDJ account was added in previous test, hence 2 accounts
assertEquals(2, accountRefs.size());
ObjectReferenceType accountRef = null;
for (ObjectReferenceType ref : accountRefs) {
if (!ref.getOid().equals(accountShadowOidOpendj)) {
accountRef = ref;
}
}
accountShadowOidDerby = accountRef.getOid();
assertFalse(accountShadowOidDerby.isEmpty());
// Check if shadow was created in the repo
repoResult = new OperationResult("getObject");
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidDerby, null, repoResult);
ShadowType repoShadowType = repoShadow.asObjectable();
repoResult.computeStatus();
TestUtil.assertSuccess("addObject has failed", repoResult);
display("Shadow (repository)", repoShadowType);
assertNotNull(repoShadowType);
assertEquals(RESOURCE_DERBY_OID, repoShadowType.getResourceRef().getOid());
// Check the "name" property, it should be set to DN, not entryUUID
assertEquals("Wrong name property", PrismTestUtil.createPolyStringType(USER_JACK_DERBY_LOGIN), repoShadowType.getName());
// check attributes in the shadow: should be only identifiers (ICF UID)
String uid = checkRepoShadow(repoShadow);
// check if account was created in DB Table
Statement stmt = derbyController.getExecutedStatementWhereLoginName(uid);
ResultSet rs = stmt.getResultSet();
System.out.println("RS: " + rs);
assertTrue("No records found for login name " + uid, rs.next());
assertEquals(USER_JACK_DERBY_LOGIN, rs.getString(DerbyController.COLUMN_LOGIN));
assertEquals("Cpt. Jack Sparrow", rs.getString(DerbyController.COLUMN_FULL_NAME));
// TODO: check password
//assertEquals("3lizab3th",rs.getString(DerbyController.COLUMN_PASSWORD));
System.out.println("Password: " + rs.getString(DerbyController.COLUMN_PASSWORD));
assertFalse("Too many records found for login name " + uid, rs.next());
rs.close();
stmt.close();
// Use getObject to test fetch of complete shadow
assertNoRepoCache();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
// WHEN
modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidDerby, options, objectHolder, resultHolder);
// THEN
assertNoRepoCache();
displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT);
TestUtil.assertSuccess("getObject has failed", resultHolder.value);
ShadowType modelShadow = (ShadowType) objectHolder.value;
display("Shadow (model)", modelShadow);
AssertJUnit.assertNotNull(modelShadow);
AssertJUnit.assertEquals(RESOURCE_DERBY_OID, modelShadow.getResourceRef().getOid());
assertAttribute(modelShadow, SchemaConstants.ICFS_UID, USER_JACK_DERBY_LOGIN);
assertAttribute(modelShadow, SchemaConstants.ICFS_NAME, USER_JACK_DERBY_LOGIN);
assertAttribute(resourceDerby, modelShadow, "FULL_NAME", "Cpt. Jack Sparrow");
}
Aggregations