Search in sources :

Example 16 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestActivation method test114ModifyUserJackEnable.

/**
 * Re-enabling the user should enable the account as well. Even if the user is already enabled.
 *
 * TODO Sure? Enabling already enabled user is a phantom change. As such, it is now filtered out.
 */
@Test
public void test114ModifyUserJackEnable() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
    // MID-6420
    ModelExecuteOptions options = ModelExecuteOptions.create(prismContext).pushChanges();
    // WHEN
    modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, options, task, result, ActivationStatusType.ENABLED);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack, USER_JACK_FULL_NAME);
    assertAdministrativeStatusEnabled(userJack);
    assertDummyEnabled(ACCOUNT_JACK_DUMMY_USERNAME);
    // No real change in effective status, therefore the enableTimestamp should be unchanged
    assertEnableTimestampFocus(userJack, null, startTime);
    assertAccounts(USER_JACK_OID, 1);
    PrismObject<ShadowType> account = getShadowModel(accountOid);
    assertAccountShadowModel(account, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, getDummyResourceType());
    assertAdministrativeStatusEnabled(account);
    assertEnableTimestampShadow(account, startTime, endTime);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) TestValidityRecomputeTask(com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 17 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestConnectorDummyFake method test400UpgradeRawReplace.

@Test
public void test400UpgradeRawReplace() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    ObjectDelta<ResourceType> resourceDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID);
    ReferenceDelta connectorRefDeltaReplace = prismContext.deltaFactory().reference().createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyOid);
    resourceDelta.addModification(connectorRefDeltaReplace);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    modelService.executeChanges(deltas, options, task, result);
    // THEN
    result.computeStatus();
    display("executeChanges result", result);
    TestUtil.assertSuccess("executeChanges result", result);
    assertUpgrade(dummyResourceModelBefore);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Example 18 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestModelServiceContract method test302ModifyAccountJackDummyBlue.

/**
 * modify account blue directly + request reconcile. check old value in delta.
 */
@Test
public void test302ModifyAccountJackDummyBlue() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    preTestCleanup(AssignmentPolicyEnforcementType.FULL);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    ObjectDelta<ShadowType> accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributeFullnamePath(), "Cpt. Jack Sparrow");
    accountDelta.addModificationReplaceProperty(getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME), "Queen Anne's Revenge");
    deltas.add(accountDelta);
    ModelExecuteOptions options = executeOptions().reconcile();
    OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation();
    when();
    modelService.executeChanges(deltas, options, task, result);
    then();
    OperationsPerformanceInformationType performanceInformation = OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
    displayValue("Operation performance (by name)", OperationsPerformanceInformationUtil.format(performanceInformation));
    displayValue("Operation performance (by time)", OperationsPerformanceInformationUtil.format(performanceInformation, new AbstractStatisticsPrinter.Options(TEXT, TIME), null, null));
    assertSuccess(result);
    // Not sure why 2 ... but this is not a big problem now
    assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    // Fullname inbound mapping is not used because it is weak
    assertUserJack(userJack, "Jack Sparrow", "Jack", "Sparrow");
    String accountJackOid = getSingleLinkOid(userJack);
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result);
    assertAccountShadowRepo(accountShadow, accountJackBlueOid, USER_JACK_USERNAME, getDummyResourceType(RESOURCE_DUMMY_BLUE_NAME));
    // Check account
    // All the changes should be reflected to the account
    modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
    assertAccountShadowRepo(accountShadow, accountJackBlueOid, USER_JACK_USERNAME, getDummyResourceType(RESOURCE_DUMMY_BLUE_NAME));
    // Check account in dummy resource
    assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, "Cpt. Jack Sparrow", true);
    // Check audit
    displayDumpable("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    // lastProvisioningTimestamp, modify account
    dummyAuditService.assertExecutionDeltas(0, 2);
    dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, ShadowType.class);
    dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributeFullnamePath(), "Jack Sparrow");
    // dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class,
    // dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME));
    dummyAuditService.assertTarget(USER_JACK_OID);
    dummyAuditService.assertExecutionSuccess();
    assertSteadyResources();
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 19 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestEditSchema method test180LookupLanguagesReplaceObject.

@Test
public void test180LookupLanguagesReplaceObject() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<LookupTableType> replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE);
    ObjectDelta<LookupTableType> delta = DeltaFactory.Object.createAddDelta(replacement);
    when();
    ModelExecuteOptions options = executeOptions().overwrite();
    options.raw(true);
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    IntegrationTestTools.display("Languages", lookup);
    assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig());
    PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
    assertNotNull("Table container missing", tableContainer);
    assertEquals("Unexpected table container size", 1, tableContainer.size());
    assertLookupRow(tableContainer, "fr_FR", "fr", "Français");
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 20 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestAssignmentValidity method test161JackAssignRoleSailorValidToRaw.

/**
 * MID-4110
 */
@Test
public void test161JackAssignRoleSailorValidToRaw() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    display("User jack before", userBefore);
    ActivationType activationType = new ActivationType();
    jackPirateValidTo = getTimestamp("PT10M");
    activationType.setValidTo(jackPirateValidTo);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    when();
    modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result);
    // THEN
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User jack after", userAfter);
    assertAssignments(userAfter, 2);
    AssignmentType assignmentSailorTypeAfter = assertAssignedRole(userAfter, ROLE_STRONG_SAILOR_OID);
    assertEffectiveActivation(assignmentSailorTypeAfter, null);
    AssignmentType assignmentPirateTypeAfter = assertAssignedRole(userAfter, ROLE_PIRATE_OID);
    assertEffectiveActivation(assignmentPirateTypeAfter, ActivationStatusType.ENABLED);
    // SAILOR is not here, we are raw
    assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID);
    assertDelegatedRef(userAfter);
    assertJackDummyPirateAccount();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)80 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)45 Test (org.testng.annotations.Test)30 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 RestartResponseException (org.apache.wicket.RestartResponseException)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3 ExecuteChangeOptionsDto (com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 NotNull (org.jetbrains.annotations.NotNull)3