Search in sources :

Example 21 with PendingOperationType

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

the class AbstractManualResourceTest method assertAccountWillAfterAssign.

private void assertAccountWillAfterAssign(final String TEST_NAME) throws Exception {
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    assertNotNull("No ID in pending operation", pendingOperation.getId());
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
    assertShadowExists(shadowRepo, false);
    assertNoShadowPassword(shadowRepo);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    assertShadowActivationAdministrativeStatusFromCache(shadowModel, ActivationStatusType.ENABLED);
    assertShadowExists(shadowModel, false);
    assertNoShadowPassword(shadowModel);
    assertSinglePendingOperation(shadowModel, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    assertNotNull("No async reference in result", willLastCaseOid);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 22 with PendingOperationType

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

the class AbstractManualResourceTest method test200ModifyUserWillFullname.

@Test
public void test200ModifyUserWillFullname() throws Exception {
    final String TEST_NAME = "test200ModifyUserWillFullname";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, accountWillOid, new ItemPath(ShadowType.F_ATTRIBUTES, ATTR_FULLNAME_QNAME), prismContext, USER_WILL_FULL_NAME_PIRATE);
    display("ObjectDelta", delta);
    accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    modifyUserReplace(userWillOid, UserType.F_FULL_NAME, task, result, createPolyString(USER_WILL_FULL_NAME_PIRATE));
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    willLastCaseOid = assertInProgress(result);
    accountWillReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    assertNotNull("No ID in pending operation", pendingOperation.getId());
    // Still old data in the repo. The operation is not completed yet.
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
    assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    assertAttributeFromBackingStore(shadowModel, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowModel);
    assertSinglePendingOperation(shadowModel, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioningFuture);
    assertNotNull("No async reference in result", willLastCaseOid);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 23 with PendingOperationType

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

the class AbstractManualResourceTest method test230ModifyAccountWillChangePasswordAndEnable.

/**
	 * Change password, enable. There is still pending disable delta. Make sure all the deltas are
	 * stored correctly.
	 */
@Test
public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception {
    final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, userWillOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, ActivationStatusType.ENABLED);
    ProtectedStringType ps = new ProtectedStringType();
    ps.setClearValue(USER_WILL_PASSWORD_NEW);
    delta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_VALUE, ps);
    display("ObjectDelta", delta);
    accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    executeChanges(delta, null, task, result);
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    willSecondLastCaseOid = assertInProgress(result);
    accountWillSecondReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 3);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    assertNotNull("No ID in pending operation", pendingOperation.getId());
    // Still old data in the repo. The operation is not completed yet.
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    PrismObject<ShadowType> shadowProvisioning = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowProvisioning);
    ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
    assertShadowName(shadowProvisioning, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioning);
    assertPendingOperationDeltas(shadowProvisioning, 3);
    pendingOperation = findPendingOperation(shadowProvisioning, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowProvisioning, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadow(shadowProvisioningFuture);
    assertNotNull("No async reference in result", willSecondLastCaseOid);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
    assertCase(willSecondLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 24 with PendingOperationType

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

the class AbstractManualResourceTest method test310CloseCaseAndRecomputeWill.

/**
	 * Case is closed. The operation is complete.
	 */
@Test
public void test310CloseCaseAndRecomputeWill() throws Exception {
    final String TEST_NAME = "test310CloseCaseAndRecomputeWill";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    closeCase(willLastCaseOid);
    accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    // We need reconcile and not recompute here. We need to fetch the updated case status.
    reconcileUser(userWillOid, task, result);
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    assertSuccess(result);
    accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    assertShadowDead(shadowRepo);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowDead(shadowModel);
    assertShadowPassword(shadowModel);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowModel, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    PrismObject<ShadowType> shadowModelFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowModelFuture);
    assertShadowName(shadowModelFuture, USER_WILL_NAME);
    assertShadowDead(shadowModelFuture);
    assertShadowPassword(shadowModelFuture);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 25 with PendingOperationType

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

the class AbstractManualResourceTest method test250RecomputeWillAfter5min.

/**
	 * lets ff 5min just for fun. Refresh, make sure everything should be the same (grace not expired yet)
	 */
@Test
public void test250RecomputeWillAfter5min() throws Exception {
    final String TEST_NAME = "test250RecomputeWillAfter5min";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    clock.overrideDuration("PT5M");
    PrismObject<ShadowType> shadowBefore = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Shadow before", shadowBefore);
    // WHEN
    displayWhen(TEST_NAME);
    recomputeUser(userWillOid, task, result);
    // THEN
    displayThen(TEST_NAME);
    assertSuccess(result);
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 3);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.SUCCESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.DISABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    if (supportsBackingStore()) {
        assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
    } else {
        assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.DISABLED);
    }
    assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowModel, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowModel);
    assertPendingOperationDeltas(shadowModel, 3);
    pendingOperation = findPendingOperation(shadowModel, OperationResultStatusType.SUCCESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowModel, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    // TODO
    //		assertShadowPassword(shadowProvisioningFuture);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
    assertCase(willSecondLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Aggregations

PendingOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType)43 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)41 Task (com.evolveum.midpoint.task.api.Task)41 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)41 Test (org.testng.annotations.Test)38 AbstractConfiguredModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)19 AbstractProvisioningIntegrationTest (com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 OperationResultStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType)4 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2