Search in sources :

Example 6 with OperationProvisioningScriptsType

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

the class TestDummy method test234DetitleAccountWillBargain.

@Test
public void test234DetitleAccountWillBargain() throws Exception {
    final String TEST_NAME = "test234DetitleAccountWillBargain";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(ACCOUNT_WILL_OID, ASSOCIATION_PRIV_NAME, PRIVILEGE_BARGAIN_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertNoMember(group, getWillRepoIcfName());
    // Make sure that account is still there and it has the privilege
    DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    Set<String> accountProvileges = dummyAccount.getAttributeValues(DummyAccount.ATTR_PRIVILEGES_NAME, String.class);
    PrismAsserts.assertSets("Wrong account privileges", accountProvileges, PRIVILEGE_NONSENSE_NAME);
    // Make sure that privilege object is still there
    DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
    assertNotNull("Privilege object is gone!", priv);
    DummyPrivilege priv2 = getDummyPrivilegeAssert(PRIVILEGE_BARGAIN_NAME, bargainIcfUid);
    assertNotNull("Privilege object (bargain) is gone!", priv);
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 7 with OperationProvisioningScriptsType

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

the class TestDummy method test133ModifyScriptNoExec.

/**
	 * This test modifies account shadow property that does NOT result in account modification
	 * on resource. The scripts must not be executed.
	 */
@Test
public void test133ModifyScriptNoExec() throws Exception {
    final String TEST_NAME = "test133ModifyScriptNoExec";
    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));
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_NEW_SCRIPT_OID, ShadowType.F_DESCRIPTION, prismContext, "Blah blah");
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, ACCOUNT_NEW_SCRIPT_OID, delta.getModifications(), scriptsType, null, 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 = getDummyAccountAssert("william", williamIcfUid);
    assertNotNull("No dummy account", dummyAccount);
    assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname"));
    assertTrue("The account is not enabled", dummyAccount.isEnabled());
    assertEquals("Wrong password", "3lizab3th123", dummyAccount.getPassword());
    IntegrationTestTools.assertScripts(dummyResource.getScriptHistory());
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 8 with OperationProvisioningScriptsType

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

the class TestDummy method test156SetValidFrom.

@Test
public void test156SetValidFrom() throws Exception {
    final String TEST_NAME = "test156SetValidFrom";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result).asObjectable();
    assertNotNull(accountType);
    display("Retrieved account shadow", accountType);
    DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    assertTrue(dummyAccount.isEnabled());
    syncServiceMock.reset();
    long millis = VALID_FROM_MILLIS;
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS));
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    // check if activation was changed
    dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    assertEquals("Wrong account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom());
    assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled());
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 9 with OperationProvisioningScriptsType

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

the class TestDummyCaseIgnore method test280EntitleAccountWillPiratesAlreadyThere.

/**
	 * Add will to the group pirates. But he is already there.
	 */
@Test
public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception {
    final String TEST_NAME = "test280EntitleAccountWillPiratesAlreadyThere";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid);
    groupPirates.addMember(getWillRepoIcfName());
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ENTITLEMENT_GROUP_NAME), GROUP_PIRATES_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertMember(group, getWillRepoIcfName());
    syncServiceMock.assertNotifySuccessOnly();
    PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Shadow after", shadow);
    assertEntitlementGroup(shadow, GROUP_PIRATES_OID);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 10 with OperationProvisioningScriptsType

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

the class TestDummy method test205ModifyGroupReplace.

@Test
public void test205ModifyGroupReplace() throws Exception {
    final String TEST_NAME = "test205ModifyGroupReplace";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    rememberDummyResourceGroupMembersReadCount(null);
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, GROUP_PIRATES_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION), prismContext, "Bloodthirsty pirates");
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertDummyAttributeValues(group, DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION, "Bloodthirsty pirates");
    if (isAvoidDuplicateValues()) {
        assertDummyResourceGroupMembersReadCountIncrement(null, 1);
    } else {
        assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    }
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)45 Task (com.evolveum.midpoint.task.api.Task)44 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)44 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)43 Test (org.testng.annotations.Test)42 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)26 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)5 ProvisioningScriptSpec (com.evolveum.midpoint.test.ProvisioningScriptSpec)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 Date (java.util.Date)2 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)1 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)1 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1