Search in sources :

Example 21 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestSanity method test300LiveSyncInit.

// Synchronization tests
/**
     * Test initialization of synchronization. It will create a cycle task and
     * check if the cycle executes No changes are synchronized yet.
     */
@Test
public void test300LiveSyncInit() throws Exception {
    final String TEST_NAME = "test300LiveSyncInit";
    TestUtil.displayTestTile(TEST_NAME);
    // Now it is the right time to add task definition to the repository
    // We don't want it there any sooner, as it may interfere with the
    // previous tests
    checkAllShadows();
    // IMPORTANT! Assignment enforcement is POSITIVE now
    setAssignmentEnforcement(AssignmentPolicyEnforcementType.POSITIVE);
    // This is not redundant. It checks that the previous command set the policy correctly
    assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType.POSITIVE);
    final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME);
    repoAddObjectFromFile(TASK_OPENDJ_SYNC_FILENAME, result);
    // We need to wait for a sync interval, so the task scanner has a chance
    // to pick up this
    // task
    waitFor("Waiting for task manager to pick up the task", new Checker() {

        public boolean check() throws ObjectNotFoundException, SchemaException {
            Task task = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result);
            display("Task while waiting for task manager to pick up the task", task);
            // wait until the task is picked up
            return task.getLastRunFinishTimestamp() != null;
        //                if (TaskExclusivityStatus.CLAIMED == task.getExclusivityStatus()) {
        //                    // wait until the first run is finished
        //                    if (task.getLastRunFinishTimestamp() == null) {
        //                        return false;
        //                    }
        //                    return true;
        //                }
        //                return false;
        }

        @Override
        public void timeout() {
        // No reaction, the test will fail right after return from this
        }
    }, 20000);
    // Check task status
    Task task = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result);
    result.computeStatus();
    display("getTask result", result);
    TestUtil.assertSuccess("getTask has failed", result);
    AssertJUnit.assertNotNull(task);
    display("Task after pickup", task);
    PrismObject<TaskType> o = repositoryService.getObject(TaskType.class, TASK_OPENDJ_SYNC_OID, null, result);
    display("Task after pickup in the repository", o.asObjectable());
    // .. it should be running
    AssertJUnit.assertEquals(TaskExecutionStatus.RUNNABLE, task.getExecutionStatus());
    // .. and claimed
    //        AssertJUnit.assertEquals(TaskExclusivityStatus.CLAIMED, task.getExclusivityStatus());
    // .. and last run should not be zero
    assertNotNull("No lastRunStartTimestamp", task.getLastRunStartTimestamp());
    assertFalse("Zero lastRunStartTimestamp", task.getLastRunStartTimestamp().longValue() == 0);
    assertNotNull("No lastRunFinishedTimestamp", task.getLastRunFinishTimestamp());
    assertFalse("Zero lastRunFinishedTimestamp", task.getLastRunFinishTimestamp().longValue() == 0);
    // Test for extension. This will also roughly test extension processor
    // and schema processor
    PrismContainer<?> taskExtension = task.getExtension();
    AssertJUnit.assertNotNull(taskExtension);
    display("Task extension", taskExtension);
    PrismProperty<String> shipStateProp = taskExtension.findProperty(MY_SHIP_STATE);
    AssertJUnit.assertEquals("Wrong 'shipState' property value", "capsized", shipStateProp.getValue().getValue());
    PrismProperty<Integer> deadProp = taskExtension.findProperty(MY_DEAD);
    PrismPropertyValue<Integer> deadPVal = deadProp.getValues().iterator().next();
    AssertJUnit.assertEquals("Wrong 'dead' property class", Integer.class, deadPVal.getValue().getClass());
    AssertJUnit.assertEquals("Wrong 'dead' property value", Integer.valueOf(42), deadPVal.getValue());
    // The progress should be 0, as there were no changes yet
    AssertJUnit.assertEquals(0, task.getProgress());
    // Test for presence of a result. It should be there and it should
    // indicate success
    OperationResult taskResult = task.getResult();
    AssertJUnit.assertNotNull(taskResult);
    assertTrue(taskResult.isSuccess());
    final Object tokenAfter = findSyncToken(task);
    display("Sync token after", tokenAfter.toString());
    lastSyncToken = (Integer) tokenAfter;
    checkAllShadows();
}
Also used : Checker(com.evolveum.midpoint.test.Checker) ObjectChecker(com.evolveum.midpoint.test.ObjectChecker) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 22 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 23 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestSanityLegacy method test420RecomputeUsers.

@Test
public void test420RecomputeUsers() throws Exception {
    final String TEST_NAME = "test420RecomputeUsers";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    final OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + "." + TEST_NAME);
    // Assign role to a user, but we do this using a repository instead of model.
    // The role assignment will not be executed and this created an inconsistent state.
    ObjectDeltaType changeAddRoleCaptain = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_1_FILENAME, ObjectDeltaType.class);
    Collection<? extends ItemDelta> modifications = DeltaConvertor.toModifications(changeAddRoleCaptain.getItemDelta(), getUserDefinition());
    repositoryService.modifyObject(UserType.class, changeAddRoleCaptain.getOid(), modifications, result);
    // TODO: setup more "inconsistent" state
    // Add reconciliation task. This will trigger reconciliation
    importObjectFromFile(TASK_USER_RECOMPUTE_FILENAME, result);
    // We need to wait for a sync interval, so the task scanner has a chance
    // to pick up this
    // task
    waitFor("Waiting for task to finish", new Checker() {

        public boolean check() throws ObjectNotFoundException, SchemaException {
            Task task = taskManager.getTask(TASK_USER_RECOMPUTE_OID, result);
            // wait until the task is finished
            if (TaskExecutionStatus.CLOSED == task.getExecutionStatus()) {
                return true;
            }
            return false;
        }

        @Override
        public void timeout() {
        // No reaction, the test will fail right after return from this
        }
    }, 40000);
    // wait a second until the task will be definitely saved
    Thread.sleep(1000);
    // Check task status
    Task task = taskManager.getTask(TASK_USER_RECOMPUTE_OID, result);
    result.computeStatus();
    display("getTask result", result);
    TestUtil.assertSuccess("getTask has failed", result);
    AssertJUnit.assertNotNull(task);
    display("Task after finish", task);
    AssertJUnit.assertNotNull(task.getTaskIdentifier());
    assertFalse(task.getTaskIdentifier().isEmpty());
    PrismObject<TaskType> o = repositoryService.getObject(TaskType.class, TASK_USER_RECOMPUTE_OID, null, result);
    display("Task after pickup in the repository", o.asObjectable());
    AssertJUnit.assertEquals(TaskExecutionStatus.CLOSED, task.getExecutionStatus());
    // .. and last run should not be zero
    assertNotNull(task.getLastRunStartTimestamp());
    AssertJUnit.assertFalse(task.getLastRunStartTimestamp().longValue() == 0);
    assertNotNull(task.getLastRunFinishTimestamp());
    AssertJUnit.assertFalse(task.getLastRunFinishTimestamp().longValue() == 0);
    AssertJUnit.assertEquals(10, task.getProgress());
    // Test for presence of a result. It should be there and it should
    // indicate success
    OperationResult taskResult = task.getResult();
    display("Recompute task result", taskResult);
    AssertJUnit.assertNotNull(taskResult);
    TestUtil.assertSuccess("Recompute task result", taskResult);
    // STOP the task. We don't need it any more and we don't want to give it a chance to run more than once
    taskManager.deleteTask(TASK_USER_RECOMPUTE_OID, result);
    // CHECK RESULT: account created for user guybrush
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> object = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
    UserType repoUser = object.asObjectable();
    repoResult.computeStatus();
    displayJaxb("User (repository)", repoUser, new QName("user"));
    List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
    assertEquals("Wrong number of accountRefs after recompute for user " + repoUser.getName(), 1, accountRefs.size());
    ObjectReferenceType accountRef = accountRefs.get(0);
    accountShadowOidGuybrushOpendj = accountRef.getOid();
    assertFalse(accountShadowOidGuybrushOpendj.isEmpty());
    // Check if shadow was created in the repo
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, repoResult);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject has failed", repoResult);
    displayJaxb("Shadow (repository)", repoShadowType, new QName("shadow"));
    assertNotNull(repoShadowType);
    assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    accountGuybrushOpendjEntryUuuid = checkRepoShadow(repoShadow);
    // check if account was created 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", "Honorable Captain");
    OpenDJController.assertAttribute(entry, "carLicense", "C4PT41N");
    OpenDJController.assertAttribute(entry, "businessCategory", "cruise");
    String guybrushPassword = OpenDJController.getAttributeValue(entry, "userPassword");
    assertNotNull("Pasword was not set on create", guybrushPassword);
    checkAllShadows();
}
Also used : Checker(com.evolveum.midpoint.test.Checker) ObjectChecker(com.evolveum.midpoint.test.ObjectChecker) Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) 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) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 24 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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());
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ResourceObjectShadowChangeDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 25 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestUniversity method getAndAssertFunctionalOrg.

//	@Test
//    public void test500ReconcileOpenDJDefault() throws Exception {
//		final String TEST_NAME = "test500ReconcileOpenDJDefault";
//        TestUtil.displayTestTile(this, TEST_NAME);
//
//        // GIVEN
//        Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME);
//        OperationResult result = task.getResult();
//        assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
//
//        List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
//        display("Users before recon", users);
//        assertUsers(15);
//
//        reconciliationTaskResultListener.clear();
//
//		// WHEN
//        TestUtil.displayWhen(TEST_NAME);
//        importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0);
//
//        users = modelService.searchObjects(UserType.class, null, null, task, result);
//        display("Users after recon", users);
//
//        assertUsers(18);
//
//        // Task result
//        PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
//        OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
//        display("Recon task result", reconTaskResult);
//        TestUtil.assertSuccess(reconTaskResult);
//	}
//
//	@Test
//    public void test502ReconcileOpenDJDefaultAgain() throws Exception {
//		final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain";
//        TestUtil.displayTestTile(this, TEST_NAME);
//
//        // GIVEN
//        Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME);
//        OperationResult result = task.getResult();
//        assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
//
//        assertUsers(18);
//        reconciliationTaskResultListener.clear();
//
//		// WHEN
//        TestUtil.displayWhen(TEST_NAME);
//        restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0);
//
//        assertUsers(18);
//
//        // Task result
//        PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
//        OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
//        display("Recon task result", reconTaskResult);
//        TestUtil.assertSuccess(reconTaskResult);
//	}
//
//	@Test
//    public void test510ReconcileOpenDJLdapGroup() throws Exception {
//		final String TEST_NAME = "test510ReconcileOpenDJLdapGroup";
//        TestUtil.displayTestTile(this, TEST_NAME);
//
//        // GIVEN
//        Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME);
//        OperationResult result = task.getResult();
//        assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
//
//        List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
//        display("Users before recon", users);
//        assertUsers(18);
//
//        reconciliationTaskResultListener.clear();
//
//		// WHEN
//        TestUtil.displayWhen(TEST_NAME);
//        importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0);
//
//        users = modelService.searchObjects(UserType.class, null, null, task, result);
//        display("Users after recon", users);
//
//        assertUsers(18);
//
//        // Task result
//        PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID);
//        OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
//        display("Recon task result", reconTaskResult);
//        TestUtil.assertSuccess(reconTaskResult);
//	}
//
//    @Test
//    public void test550ReconcileOpenDJAfterMembershipChange() throws Exception {
//        final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange";
//        TestUtil.displayTestTile(this, TEST_NAME);
//
//        // We manually remove Lemonhead from R_canibalism group
//        // And check whether reconciliation re-adds him again
//
//        // GIVEN
//        Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME);
//        OperationResult result = task.getResult();
//        assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
//
//        Collection<String> membersBeforeTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN);
//        System.out.println("group members before test = " + membersBeforeTest);
//        assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersBeforeTest.contains(ACCOUNT_LEMONHEAD_DN));
//
//        openDJController.removeGroupUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN);
//
//        System.out.println("group members after removal = " + openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN));
//
//        openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN);
//
//        // WHEN
//        TestUtil.displayWhen(TEST_NAME);
//        restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false);
//
//        // THEN
//        TestUtil.displayThen(TEST_NAME);
//
//        // Task result
//        PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID);
//        OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
//        display("Recon task result", reconTaskResult);
//        TestUtil.assertSuccess(reconTaskResult);
//
//        Collection<String> membersAfterTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN);
//        System.out.println("group members after test = " + membersAfterTest);
//        assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersAfterTest.contains(ACCOUNT_LEMONHEAD_DN.toLowerCase()));    // ...it seems to get lowercased during the reconciliation
//    }
private PrismObject<OrgType> getAndAssertFunctionalOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException {
    PrismObject<OrgType> org = getOrg(orgName);
    PrismAsserts.assertPropertyValue(org, OrgType.F_ORG_TYPE, "functional");
    assertAssignedRole(org, ROLE_META_ORG_OID);
    String ouOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.GENERIC, "org-ou");
    PrismObject<ShadowType> ouShadow = getShadowModel(ouOid);
    display("Org " + orgName + " OU shadow", ouShadow);
    // TODO assert shadow content
    String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group");
    PrismObject<ShadowType> groupShadow = getShadowModel(groupOid);
    display("Org " + orgName + " group shadow", groupShadow);
    // TODO assert shadow content
    Entry ouEntry = openDJController.searchSingle("ou=" + orgName);
    assertNotNull("No ou LDAP entry for " + orgName, ouEntry);
    display("OU entry", ouEntry);
    openDJController.assertObjectClass(ouEntry, "organizationalUnit");
    Entry groupEntry = openDJController.searchSingle("cn=DL-" + orgName);
    assertNotNull("No group LDAP entry for " + orgName, groupEntry);
    display("OU GROUP entry", groupEntry);
    openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames");
    return org;
}
Also used : SearchResultEntry(org.opends.server.types.SearchResultEntry) Entry(org.opends.server.types.Entry) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Aggregations

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8