Search in sources :

Example 11 with ProvisioningScriptSpec

use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.

the class TestNotifications method assertDummyScriptsModify.

private void assertDummyScriptsModify(PrismObject<UserType> user, boolean recon) {
    ProvisioningScriptSpec modScript = new ProvisioningScriptSpec("Beware the Jabberwock, my son!");
    String name = null;
    String fullName = null;
    String costCenter = null;
    if (user != null) {
        name = user.asObjectable().getName().getOrig();
        fullName = user.asObjectable().getFullName().getOrig();
        costCenter = user.asObjectable().getCostCenter();
    }
    modScript.addArgSingle("howMuch", costCenter);
    modScript.addArgSingle("howLong", "from here to there");
    modScript.addArgSingle("who", name);
    modScript.addArgSingle("whatchacallit", fullName);
    if (recon) {
        ProvisioningScriptSpec reconBeforeScript = new ProvisioningScriptSpec("The vorpal blade went snicker-snack!");
        reconBeforeScript.addArgSingle("who", name);
        ProvisioningScriptSpec reconAfterScript = new ProvisioningScriptSpec("He left it dead, and with its head");
        reconAfterScript.addArgSingle("how", "enabled");
        IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), reconBeforeScript, modScript, reconAfterScript);
    } else {
        IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), modScript);
    }
}
Also used : ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

Example 12 with ProvisioningScriptSpec

use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.

the class TestNotifications method assertDummyScriptsDelete.

private void assertDummyScriptsDelete() {
    ProvisioningScriptSpec script = new ProvisioningScriptSpec("The Jabberwock, with eyes of flame");
    IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
Also used : ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

Example 13 with ProvisioningScriptSpec

use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.

the class TestImportRecon method test200ReconcileDummy.

@Test
public void test200ReconcileDummy() throws Exception {
    final String TEST_NAME = "test200ReconcileDummy";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    // Lets do some local changes on dummy resource
    DummyAccount guybrushDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    // fullname has a normal outbound mapping, this change should NOT be corrected
    guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Dubrish Freepweed");
    // location has strong outbound mapping, this change should be corrected
    guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Forbidded Dodecahedron");
    // Weapon has a weak mapping, this change should be left as it is
    guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Feather duster");
    // Drink is not tolerant. The extra values should be removed
    guybrushDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water");
    // Quote is tolerant. The extra values should stay as it is
    guybrushDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "I want to be a pirate!");
    // Calypso is protected, this should not reconcile
    DummyAccount calypsoDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
    calypsoDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
    PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
    display("User rapp before", userRappBefore);
    PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT, PrismTestUtil.createPolyString("The crew of The Elaine"));
    getDummyResource().purgeScriptHistory();
    dummyAuditService.clear();
    rememberShadowFetchOperationCount();
    reconciliationTaskResultListener.clear();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE_FILE);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertShadowFetchOperationCountIncrement(3);
    reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after import", users);
    assertImportedUserByOid(USER_ADMINISTRATOR_OID);
    assertImportedUserByOid(USER_JACK_OID);
    assertImportedUserByOid(USER_BARBOSSA_OID);
    assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
    // Guybrushes fullname should NOT be corrected back to real fullname
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Dubrish Freepweed");
    // Guybrushes location should be corrected back to real value
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
    // Guybrushes weapon should be left untouched
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Feather duster");
    // Guybrushes drink should be corrected
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
    // Guybrushes quotes should be left untouched
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Arr!", "I want to be a pirate!");
    assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
    PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
    display("User rapp after", userRappAfter);
    PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT, PrismTestUtil.createPolyString("The crew of The Elaine"));
    assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
    // These are protected accounts, they should not be imported
    assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
    assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
    // Calypso is protected account. Reconciliation should not touch it
    assertDummyAccountAttribute(null, ACCOUNT_CALYPSO_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
    assertEquals("Unexpected number of users", 10, users.size());
    display("Dummy resource", getDummyResource().debugDump());
    display("Script history", getDummyResource().getScriptHistory());
    ArrayList<ProvisioningScriptSpec> scripts = new ArrayList<ProvisioningScriptSpec>();
    addReconScripts(scripts, ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", false);
    addReconScripts(scripts, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
    addReconScripts(scripts, ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", false);
    addReconScripts(scripts, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, false);
    addReconScripts(scripts, ACCOUNT_STAN_NAME, ACCOUNT_STAN_FULLNAME, false);
    IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), scripts.toArray(new ProvisioningScriptSpec[0]));
    assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_OID);
    // Task result
    PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_OID);
    OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
    display("Recon task result", reconTaskResult);
    TestUtil.assertSuccess(reconTaskResult);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec) PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 14 with ProvisioningScriptSpec

use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.

the class TestImportRecon method addReconScripts.

private void addReconScripts(Collection<ProvisioningScriptSpec> scripts, String username, String fullName, boolean modified, boolean afterRecon) {
    // before recon
    ProvisioningScriptSpec script = new ProvisioningScriptSpec("The vorpal blade went snicker-snack!");
    script.addArgSingle("who", username);
    scripts.add(script);
    if (modified) {
        script = new ProvisioningScriptSpec("Beware the Jabberwock, my son!");
        script.addArgSingle("howMuch", null);
        script.addArgSingle("howLong", "from here to there");
        script.addArgSingle("who", username);
        script.addArgSingle("whatchacallit", fullName);
        scripts.add(script);
    }
    if (afterRecon) {
        // after recon
        script = new ProvisioningScriptSpec("He left it dead, and with its head");
        script.addArgSingle("how", "enabled");
        scripts.add(script);
    }
}
Also used : ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

Example 15 with ProvisioningScriptSpec

use of com.evolveum.midpoint.test.ProvisioningScriptSpec in project midpoint by Evolveum.

the class TestDummy method test134DeleteScript.

@Test
public void test134DeleteScript() throws Exception {
    final String TEST_NAME = "test134DeleteScript";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    dummyResource.purgeScriptHistory();
    OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class);
    display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType));
    // WHEN
    provisioningService.deleteObject(ShadowType.class, ACCOUNT_NEW_SCRIPT_OID, null, scriptsType, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess("modifyObject has failed (result)", result);
    syncServiceMock.assertNotifySuccessOnly();
    // Check if the account was modified in the dummy resource
    DummyAccount dummyAccount = getDummyAccount("william", williamIcfUid);
    assertNull("Dummy account not gone", dummyAccount);
    ProvisioningScriptSpec beforeScript = new ProvisioningScriptSpec("Goodbye World");
    beforeScript.addArgMulti("what", "cruel");
    ProvisioningScriptSpec afterScript = new ProvisioningScriptSpec("R.I.P.");
    IntegrationTestTools.assertScripts(dummyResource.getScriptHistory(), beforeScript, afterScript);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Aggregations

ProvisioningScriptSpec (com.evolveum.midpoint.test.ProvisioningScriptSpec)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 Test (org.testng.annotations.Test)9 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)6 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)5 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 ArrayList (java.util.ArrayList)5 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ProvisioningScriptType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType)1