Search in sources :

Example 26 with OperationProvisioningScriptsType

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

the class TestDummy method test158DeleteValidToValidFrom.

@Test
public void test158DeleteValidToValidFrom() throws Exception {
    final String TEST_NAME = "test158DeleteValidToValidFrom";
    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_TO_MILLIS;
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS));
    PrismObjectDefinition<ShadowType> def = accountType.asPrismObject().getDefinition();
    PropertyDelta<XMLGregorianCalendar> validFromDelta = PropertyDelta.createModificationDeleteProperty(SchemaConstants.PATH_ACTIVATION_VALID_FROM, def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_VALID_FROM), XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS));
    delta.addModification(validFromDelta);
    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);
    assertNull("Unexpected account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo());
    assertNull("Unexpected account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom());
    assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled());
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) 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 27 with OperationProvisioningScriptsType

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

the class TestDummy method test152ActivationStatusUndefinedAccount.

@Test
public void test152ActivationStatusUndefinedAccount() throws Exception {
    final String TEST_NAME = "test152ActivationStatusUndefinedAccount";
    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);
    assertFalse("Account is not disabled", dummyAccount.isEnabled());
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, ActivationStatusType.DISABLED);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    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 dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " enabled flag", null, 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) Test(org.testng.annotations.Test)

Example 28 with OperationProvisioningScriptsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType 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)

Example 29 with OperationProvisioningScriptsType

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

the class TestDummy method test157SetValidTo.

@Test
public void test157SetValidTo() throws Exception {
    final String TEST_NAME = "test157SetValidTo";
    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_TO_MILLIS;
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_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());
    assertEquals("Wrong account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_TO_MILLIS), dummyAccount.getValidTo());
    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 30 with OperationProvisioningScriptsType

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

the class TestDummyCaseIgnore method test289DetitleAccountWillPirates.

@Test
public void test289DetitleAccountWillPirates() throws Exception {
    final String TEST_NAME = "test289DetitleAccountWillPirates";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(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);
    assertNoMember(group, getWillRepoIcfName());
    assertNoMember(group, getWillRepoIcfName().toUpperCase());
    assertNoMember(group, getWillRepoIcfName().toLowerCase());
    // Make sure that account is still there and it has the privilege
    DummyAccount dummyAccount = getDummyAccountAssert(ACCOUNT_WILL_USERNAME, willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    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) 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