Search in sources :

Example 6 with ProvisioningScriptSpec

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

the class TestImportRecon method test229ReconcileDummyFixed.

/**
	 * Simply re-run recon after the resource is fixed. This should correct the data.
	 */
@Test
public void test229ReconcileDummyFixed() throws Exception {
    final String TEST_NAME = "test229ReconcileDummyFixed";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    // Fix it!
    getDummyResource().setBreakMode(BreakMode.NONE);
    getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME).setModifyBreakMode(BreakMode.NONE);
    getDummyResource().purgeScriptHistory();
    dummyAuditService.clear();
    rememberShadowFetchOperationCount();
    reconciliationTaskResultListener.clear();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    restartTask(TASK_RECONCILE_DUMMY_OID);
    waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
    // 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);
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Dubrish Freepweed");
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Feather duster");
    assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
    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);
    assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
    assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
    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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 7 with ProvisioningScriptSpec

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

the class TestModelServiceContract method assertDummyScriptsAdd.

private void assertDummyScriptsAdd(PrismObject<UserType> user, PrismObject<? extends ShadowType> account, ResourceType resource) {
    ProvisioningScriptSpec script = new ProvisioningScriptSpec("\nto spiral :size\n" + "   if  :size > 30 [stop]\n   fd :size rt 15\n   spiral :size *1.02\nend\n			");
    String userName = null;
    if (user != null) {
        userName = user.asObjectable().getName().getOrig();
    }
    script.addArgSingle("usr", "user: " + userName);
    // Note: We cannot test for account name as name is only assigned in provisioning
    String accountEnabled = null;
    if (account != null && account.asObjectable().getActivation() != null && account.asObjectable().getActivation().getAdministrativeStatus() != null) {
        accountEnabled = account.asObjectable().getActivation().getAdministrativeStatus().toString();
    }
    script.addArgSingle("acc", "account: " + accountEnabled);
    String resourceName = null;
    if (resource != null) {
        resourceName = resource.getName().getOrig();
    }
    script.addArgSingle("res", "resource: " + resourceName);
    script.addArgSingle("size", "3");
    script.setLanguage("Logo");
    IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

Example 8 with ProvisioningScriptSpec

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

the class TestModelServiceContract 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 : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

Example 9 with ProvisioningScriptSpec

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

the class TestModelServiceContract 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 10 with ProvisioningScriptSpec

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

the class TestNotifications method assertDummyScriptsAdd.

private void assertDummyScriptsAdd(PrismObject<UserType> user, PrismObject<? extends ShadowType> account, ResourceType resource) {
    ProvisioningScriptSpec script = new ProvisioningScriptSpec("\nto spiral :size\n" + "   if  :size > 30 [stop]\n   fd :size rt 15\n   spiral :size *1.02\nend\n			");
    String userName = null;
    if (user != null) {
        userName = user.asObjectable().getName().getOrig();
    }
    script.addArgSingle("usr", "user: " + userName);
    // Note: We cannot test for account name as name is only assigned in provisioning
    String accountEnabled = null;
    if (account != null && account.asObjectable().getActivation() != null && account.asObjectable().getActivation().getAdministrativeStatus() != null) {
        accountEnabled = account.asObjectable().getActivation().getAdministrativeStatus().toString();
    }
    script.addArgSingle("acc", "account: " + accountEnabled);
    String resourceName = null;
    if (resource != null) {
        resourceName = resource.getName().getOrig();
    }
    script.addArgSingle("res", "resource: " + resourceName);
    script.addArgSingle("size", "3");
    script.setLanguage("Logo");
    IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), script);
}
Also used : ProvisioningScriptSpec(com.evolveum.midpoint.test.ProvisioningScriptSpec)

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