Search in sources :

Example 26 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestDummyNoActivation method test154EnableAccount.

@Test
@Override
public void test154EnableAccount() throws Exception {
    final String TEST_NAME = "test154EnableAccount";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, prismContext, ActivationStatusType.ENABLED);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    try {
        // WHEN
        provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (SchemaException e) {
    // This is expected
    }
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertFailure(result);
    delta.checkConsistence();
    // check if activation was unchanged
    DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_WILL_USERNAME);
    assertTrue("Dummy account " + ACCOUNT_WILL_USERNAME + " is disabled, expected enabled", dummyAccount.isEnabled());
    syncServiceMock.assertNotifyFailureOnly();
    assertSteadyResource();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) 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 DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractInternalModelIntegrationTest method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    logger.trace("initSystem");
    super.initSystem(initTask, initResult);
    // We want logging config from logback-test.xml and not from system config object (unless suppressed)
    InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange());
    mockClockworkHook = new MockClockworkHook();
    hookRegistry.registerChangeHook(MOCK_CLOCKWORK_HOOK_URL, mockClockworkHook);
    modelService.postInit(initResult);
    // System Configuration
    try {
        repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    repoAddObjectFromFile(SECURITY_POLICY_FILE, initResult);
    // Administrator
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    login(userAdministrator);
    // User Templates
    repoAddObjectFromFile(USER_TEMPLATE_FILE, initResult);
    // Resources
    initDummyResourcePirate(null, RESOURCE_DUMMY_FILE, RESOURCE_DUMMY_OID, initTask, initResult);
    // We need to create Barbossa's account in exactly the shape that is given by his existing assignments
    // otherwise any substantial change will trigger reconciliation and the recon changes will interfere with
    // the tests
    DummyAccount account = new DummyAccount(ACCOUNT_HBARBOSSA_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Hector Barbossa");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Caribbean");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Pirate Brethren, Inc.");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Undead Monkey");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Arr!");
    getDummyResource().addAccount(account);
    getDummyResourceController().addAccount(ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", "Monkey Island");
    getDummyResourceController().addAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", "Melee Island");
    // Accounts
    repoAddObjectFromFile(ACCOUNT_HBARBOSSA_DUMMY_FILE, initResult);
    repoAddObjectFromFile(ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE, initResult);
    repoAddObjectFromFile(ACCOUNT_SHADOW_ELAINE_DUMMY_FILE, initResult);
    // Users
    userTypeJack = repoAddObjectFromFile(USER_JACK_FILE, UserType.class, initResult).asObjectable();
    userTypeBarbossa = repoAddObjectFromFile(USER_BARBOSSA_FILE, UserType.class, initResult).asObjectable();
    userTypeGuybrush = repoAddObjectFromFile(USER_GUYBRUSH_FILE, UserType.class, initResult).asObjectable();
    userTypeElaine = repoAddObjectFromFile(USER_ELAINE_FILE, UserType.class, initResult).asObjectable();
}
Also used : MockClockworkHook(com.evolveum.midpoint.model.impl.util.mock.MockClockworkHook) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 28 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestSynchronizationService method test200AddedAccountJackSchemaViolation.

/**
 * Schema violation error on the connector while doing synchronization.
 * While we cannot really execute any connector operation (e.g. we cannot
 * reconcile), we still want the shadow linked to the user.
 * MID-3787
 */
@Test
public void test200AddedAccountJackSchemaViolation() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    assertLiveLinks(userBefore, 0);
    setDebugListener();
    PrismObject<ShadowType> accountShadowJack = repoAddObjectFromFile(ACCOUNT_SHADOW_JACK_DUMMY_FILE, result);
    accountShadowJackDummyOid = accountShadowJack.getOid();
    provisioningService.applyDefinition(accountShadowJack, task, result);
    provisioningService.determineShadowState(accountShadowJack, task, result);
    assertNotNull("No oid in shadow", accountShadowJack.getOid());
    DummyAccount dummyAccount = new DummyAccount();
    dummyAccount.setName(ACCOUNT_JACK_DUMMY_USERNAME);
    dummyAccount.setPassword("deadMenTellNoTales");
    dummyAccount.setEnabled(true);
    dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    getDummyResource().addAccount(dummyAccount);
    displayDumpable("Dummy resource before", getDummyResource());
    getDummyResource().setModifyBreakMode(BreakMode.SCHEMA);
    ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
    change.setShadowedResourceObject(accountShadowJack);
    change.setResource(getDummyResourceObject());
    change.setSourceChannel(SchemaConstants.CHANNEL_LIVE_SYNC_URI);
    // WHEN
    when();
    synchronizationService.notifyChange(change, task, result);
    // THEN
    then();
    getDummyResource().resetBreakMode();
    assertPartialError(result);
    LensContext<UserType> context = cleanDebugListener();
    displayDumpable("Resulting context (as seen by debug listener)", context);
    assertNotNull("No resulting context (as seen by debug listener)", context);
    assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null, null, false);
    LensProjectionContext accCtx = context.findProjectionContext(rat);
    assertNotNull("No account sync context for " + rat, accCtx);
    assertEquals("Wrong detected situation in context", SynchronizationSituationType.UNLINKED, accCtx.getSynchronizationSituationDetected());
    assertEquals("Wrong resolved situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationResolved());
    PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
    assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    assertLiveLinks(userAfter, 1);
    PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
    assertSituation(shadow, SynchronizationSituationType.LINKED);
    assertLinked(userAfter, shadow);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 29 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestSynchronizationService method test010AddedAccountJack.

@Test
public void test010AddedAccountJack() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    setDebugListener();
    PrismObject<ShadowType> accountShadowJack = repoAddObjectFromFile(ACCOUNT_SHADOW_JACK_DUMMY_FILE, result);
    accountShadowJackDummyOid = accountShadowJack.getOid();
    provisioningService.applyDefinition(accountShadowJack, task, result);
    provisioningService.determineShadowState(accountShadowJack, task, result);
    assertNotNull("No oid in shadow", accountShadowJack.getOid());
    DummyAccount dummyAccount = new DummyAccount();
    dummyAccount.setName(ACCOUNT_JACK_DUMMY_USERNAME);
    dummyAccount.setPassword("deadMenTellNoTales");
    dummyAccount.setEnabled(true);
    dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    getDummyResource().addAccount(dummyAccount);
    ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
    change.setShadowedResourceObject(accountShadowJack);
    change.setResource(getDummyResourceObject());
    change.setSourceChannel(SchemaConstants.CHANNEL_LIVE_SYNC_URI);
    // WHEN
    synchronizationService.notifyChange(change, task, result);
    // THEN
    assertSuccess(result);
    LensContext<UserType> context = cleanDebugListener();
    displayDumpable("Resulting context (as seen by debug listener)", context);
    assertNotNull("No resulting context (as seen by debug listener)", context);
    assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null, null, false);
    LensProjectionContext accCtx = context.findProjectionContext(rsd);
    assertNotNull("No projection context for " + rsd, accCtx);
    assertEquals("Wrong detected situation in context", SynchronizationSituationType.UNLINKED, accCtx.getSynchronizationSituationDetected());
    assertEquals("Wrong resolved situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationResolved());
    PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
    // it this really expected?? delta was already executed, should we expect it in the secondary delta?
    // assertNotNull("Missing account secondary delta", accCtx.getSecondaryDelta());
    // assertIterationDelta(accCtx.getSecondaryDelta(), 0, "");
    assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
    PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
    assertIteration(shadow, 0, "");
    assertSituation(shadow, SynchronizationSituationType.LINKED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 30 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestSynchronizationService method test100AddedAccountJack.

@Test
public void test100AddedAccountJack() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    assertUserBefore(USER_JACK_OID).assertLiveLinks(0).assertRelatedLinks(0);
    setDebugListener();
    PrismObject<ShadowType> accountShadowJack = repoAddObjectFromFile(ACCOUNT_SHADOW_JACK_DUMMY_FILE, result);
    accountShadowJackDummyOid = accountShadowJack.getOid();
    provisioningService.applyDefinition(accountShadowJack, task, result);
    provisioningService.determineShadowState(accountShadowJack, task, result);
    assertNotNull("No oid in shadow", accountShadowJack.getOid());
    DummyAccount dummyAccount = new DummyAccount();
    dummyAccount.setName(ACCOUNT_JACK_DUMMY_USERNAME);
    dummyAccount.setPassword("deadMenTellNoTales");
    dummyAccount.setEnabled(true);
    dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    getDummyResource().addAccount(dummyAccount);
    displayDumpable("Dummy resource before", getDummyResource());
    ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
    change.setShadowedResourceObject(accountShadowJack);
    change.setResource(getDummyResourceObject());
    change.setSourceChannel(SchemaConstants.CHANNEL_LIVE_SYNC_URI);
    // WHEN
    when();
    synchronizationService.notifyChange(change, task, result);
    // THEN
    then();
    assertSuccess(result);
    LensContext<UserType> context = cleanDebugListener();
    displayDumpable("Resulting context (as seen by debug listener)", context);
    assertNotNull("No resulting context (as seen by debug listener)", context);
    assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null, null, false);
    LensProjectionContext accCtx = context.findProjectionContext(rat);
    assertNotNull("No account sync context for " + rat, accCtx);
    assertEquals("Wrong detected situation in context", SynchronizationSituationType.UNLINKED, accCtx.getSynchronizationSituationDetected());
    assertEquals("Wrong resolved situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationResolved());
    PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
    // it this really expected?? delta was already executed, should we expect it in the secondary delta?
    assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
    PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
    assertIteration(shadow, 0, "");
    assertSituation(shadow, SynchronizationSituationType.LINKED);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    assertLiveLinks(userAfter, 1);
    assertLinked(userAfter, shadow);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestTask(com.evolveum.midpoint.test.TestTask) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)261 Test (org.testng.annotations.Test)211 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)158 Task (com.evolveum.midpoint.task.api.Task)152 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)40 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)24 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 ArrayList (java.util.ArrayList)19 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)18 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)10 QName (javax.xml.namespace.QName)10 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)9 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)9