Search in sources :

Example 1 with PropertyReferenceListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType 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
}
Also used : PropertyReferenceListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType) 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) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) 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 PropertyReferenceListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType in project midpoint by Evolveum.

the class TestSanityLegacy 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
}
Also used : PropertyReferenceListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType) 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) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with PropertyReferenceListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType in project midpoint by Evolveum.

the class ConsistencyTest method test110PrepareOpenDjWithAccounts.

/**
	 * Add account to user. This should result in account provisioning. Check if
	 * that happens in repo and in LDAP.
	 */
@Test
public void test110PrepareOpenDjWithAccounts() throws Exception {
    final String TEST_NAME = "test110PrepareOpenDjWithAccounts";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult parentResult = new OperationResult(TEST_NAME);
    ShadowType jackeAccount = unmarshallValueFromFile(REQUEST_ADD_ACCOUNT_JACKIE, ShadowType.class);
    Task task = taskManager.createTaskInstance();
    String oid = provisioningService.addObject(jackeAccount.asPrismObject(), null, null, task, parentResult);
    PrismObject<ShadowType> jackFromRepo = repositoryService.getObject(ShadowType.class, oid, null, parentResult);
    LOGGER.debug("account jack after provisioning: {}", jackFromRepo.debugDump());
    PrismObject<UserType> jackUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, parentResult);
    ObjectReferenceType ort = new ObjectReferenceType();
    ort.setOid(oid);
    ort.setType(ShadowType.COMPLEX_TYPE);
    jackUser.asObjectable().getLinkRef().add(ort);
    PrismObject<UserType> jackUserRepo = repositoryService.getObject(UserType.class, USER_JACK_OID, null, parentResult);
    ObjectDelta delta = DiffUtil.diff(jackUserRepo, jackUser);
    repositoryService.modifyObject(UserType.class, USER_JACK_OID, delta.getModifications(), parentResult);
    // GIVEN
    OperationResult repoResult = new OperationResult("getObject");
    // Check if user object was modified in the repo
    accountShadowOidOpendj = assertUserOneAccountRef(USER_JACK_OID);
    assertFalse(accountShadowOidOpendj.isEmpty());
    // Check if shadow was created in the repo
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject has failed", repoResult);
    display("Shadow (repository)", repoShadow);
    assertNotNull(repoShadowType);
    assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    assertNotNull("Shadow stored in repository has no name", repoShadowType.getName());
    // Check the "name" property, it should be set to DN, not entryUUID
    assertEquals("Wrong name property", USER_JACK_LDAP_DN.toLowerCase(), repoShadowType.getName().getOrig().toLowerCase());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // check if account was created in LDAP
    Entry entry = openDJController.searchAndAssertByEntryUuid(uid);
    display("LDAP account", entry);
    OpenDJController.assertAttribute(entry, "uid", "jackie");
    OpenDJController.assertAttribute(entry, "givenName", "Jack");
    OpenDJController.assertAttribute(entry, "sn", "Sparrow");
    OpenDJController.assertAttribute(entry, "cn", "Jack Sparrow");
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    // WHEN
    PropertyReferenceListType resolve = new PropertyReferenceListType();
    //		List<ObjectOperationOptions> options = new ArrayList<ObjectOperationOptions>();
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, null, 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_OPENDJ_OID, modelShadow.getResourceRef().getOid());
    assertAttributeNotNull(modelShadow, getOpenDjPrimaryIdentifierQName());
    assertAttributes(modelShadow, "jackie", "Jack", "Sparrow", "Jack Sparrow");
    // "middle of nowhere");
    assertNull("carLicense attribute sneaked to LDAP", OpenDJController.getAttributeValue(entry, "carLicense"));
    assertNotNull("Activation is null", modelShadow.getActivation());
    assertNotNull("No 'enabled' in the shadow", modelShadow.getActivation().getAdministrativeStatus());
    assertEquals("The account is not enabled in the shadow", ActivationStatusType.ENABLED, modelShadow.getActivation().getAdministrativeStatus());
    TestUtil.displayTestTile("test013prepareOpenDjWithAccounts - add second account");
    OperationResult secondResult = new OperationResult("test013prepareOpenDjWithAccounts - add second account");
    ShadowType shadow = unmarshallValueFromFile(ACCOUNT_DENIELS_FILENAME, ShadowType.class);
    provisioningService.addObject(shadow.asPrismObject(), null, null, task, secondResult);
    repoAddObjectFromFile(USER_DENIELS_FILENAME, secondResult);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PropertyReferenceListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) Entry(org.opends.server.types.Entry) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 4 with PropertyReferenceListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType in project midpoint by Evolveum.

the class ConsistencyTest method test100AddUser.

/**
	 * Attempt to add new user. It is only added to the repository, so check if
	 * it is in the repository after the operation.
	 */
@Test
public void test100AddUser() throws Exception {
    final String TEST_NAME = "test100AddUser";
    UserType userType = testAddUserToRepo(TEST_NAME, USER_JACK_FILENAME, USER_JACK_OID);
    OperationResult repoResult = new OperationResult("getObject");
    PropertyReferenceListType resolve = new PropertyReferenceListType();
    PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    repoResult.computeStatus();
    display("repository.getObject result", repoResult);
    TestUtil.assertSuccess("getObject has failed", repoResult);
    AssertJUnit.assertEquals(USER_JACK_OID, repoUser.getOid());
    PrismAsserts.assertEqualsPolyString("User full name not equals as expected.", userType.getFullName(), repoUser.getFullName());
// TODO: better checks
}
Also used : PropertyReferenceListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 PropertyReferenceListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 Test (org.testng.annotations.Test)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)2 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 Task (com.evolveum.midpoint.task.api.Task)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 Holder (javax.xml.ws.Holder)1 Entry (org.opends.server.types.Entry)1