Search in sources :

Example 96 with ShadowType

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

the class AbstractInboundSyncTest method assertShadowOperationalData.

protected void assertShadowOperationalData(PrismObject<ShadowType> shadow, SynchronizationSituationType expectedSituation) {
    ShadowType shadowType = shadow.asObjectable();
    SynchronizationSituationType actualSituation = shadowType.getSynchronizationSituation();
    assertEquals("Wrong situation in shadow " + shadow, expectedSituation, actualSituation);
    XMLGregorianCalendar actualTimestampCal = shadowType.getSynchronizationTimestamp();
    assert actualTimestampCal != null : "No synchronization timestamp in shadow " + shadow;
    long actualTimestamp = XmlTypeConverter.toMillis(actualTimestampCal);
    assert actualTimestamp >= timeBeforeSync : "Synchronization timestamp was not updated in shadow " + shadow;
// TODO: assert sync description
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 97 with ShadowType

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

the class AbstractObjTemplateSyncTest method assertShadowOperationalData.

protected void assertShadowOperationalData(PrismObject<ShadowType> shadow, SynchronizationSituationType expectedSituation) {
    ShadowType shadowType = shadow.asObjectable();
    SynchronizationSituationType actualSituation = shadowType.getSynchronizationSituation();
    assertEquals("Wrong situation in shadow " + shadow, expectedSituation, actualSituation);
    XMLGregorianCalendar actualTimestampCal = shadowType.getSynchronizationTimestamp();
    assert actualTimestampCal != null : "No synchronization timestamp in shadow " + shadow;
    long actualTimestamp = XmlTypeConverter.toMillis(actualTimestampCal);
    assert actualTimestamp >= timeBeforeSync : "Synchronization timestamp was not updated in shadow " + shadow;
// TODO: assert sync description
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 98 with ShadowType

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

the class AbstractSynchronizationStoryTest method test600AddDummyGreenAccountCalypso.

/**
	 * Calypso is a protected account. It should not be touched by the sync.
	 */
@Test
public void test600AddDummyGreenAccountCalypso() throws Exception {
    final String TEST_NAME = "test600AddDummyGreenAccountCalypso";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(7 + getNumberOfExtraDummyUsers());
    DummyAccount account = new DummyAccount(ACCOUNT_CALYPSO_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas");
    /// WHEN
    TestUtil.displayWhen(TEST_NAME);
    dummyResourceGreen.addAccount(account);
    waitForSyncTaskNextRunAssertSuccess(resourceDummyGreen);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<ShadowType> accountShadow = findAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME, resourceDummyGreen);
    display("Account calypso", accountShadow);
    assertNotNull("No calypso account shadow", accountShadow);
    assertEquals("Wrong resourceRef in calypso account", RESOURCE_DUMMY_GREEN_OID, accountShadow.asObjectable().getResourceRef().getOid());
    assertTrue("Calypso shadow is NOT protected", accountShadow.asObjectable().isProtectedObject());
    PrismObject<UserType> userCalypso = findUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
    display("User calypso", userCalypso);
    assertNull("User calypso was created, it should not", userCalypso);
    assertUsers(7 + getNumberOfExtraDummyUsers());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 99 with ShadowType

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

the class AbstractSynchronizationStoryTest method test382ModifyUserWallyLocality.

/**
	 * Change user locality. Locality has strong mapping on default dummy. 
	 * See if the change propagates correctly. Also see that there are no side-effects.
	 */
@Test
public void test382ModifyUserWallyLocality() throws Exception {
    final String TEST_NAME = "test382ModifyUserWallyLocality";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    rememberTimeBeforeSync();
    prepareNotifications();
    DummyAccount wallyDummyAccount = dummyResourceGreen.getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME);
    /// WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyUserReplace(userWallyOid, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Plunder island"));
    // Wait for sync tasks to pick up the change and have some chance to screw things
    waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject());
    waitForSyncTaskNextRunAssertSuccess(resourceDummyBlue);
    waitForSyncTaskNextRunAssertSuccess(resourceDummyGreen);
    // Run green recon twice here. If the recon already searched for current state of the
    // wally account, the old value is stored in the memory. Even if we rewrite
    // the account state by this operation the value already read into memory will be used instead
    // and it will be propagated to other resources. The next recon run should fix it.
    // Both in user and on the resource.
    waitForSyncTaskNextRunAssertSuccess(resourceDummyGreen);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<UserType> userWally = findUserByUsername(ACCOUNT_WALLY_DUMMY_USERNAME);
    display("User wally", userWally);
    assertNotNull("User wally disappeared", userWally);
    assertUser(userWally, userWallyOid, ACCOUNT_WALLY_DUMMY_USERNAME, "Bloodnose", null, "Bloodnose from Sync");
    PrismAsserts.assertPropertyValue(userWally, UserType.F_LOCALITY, PrismTestUtil.createPolyString("Plunder island"));
    PrismObject<ShadowType> accountWallyBlue = checkWallyAccount(resourceDummyBlue, dummyResourceBlue, "blue", "Wally Feed");
    if (allwaysCheckTimestamp)
        assertShadowOperationalData(accountWallyBlue, SynchronizationSituationType.LINKED);
    PrismObject<ShadowType> accountWallyGreen = checkWallyAccount(resourceDummyGreen, dummyResourceGreen, "green", "Bloodnose");
    assertShadowOperationalData(accountWallyGreen, SynchronizationSituationType.LINKED);
    PrismObject<ShadowType> accountWallyDefault = findAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME, getDummyResourceObject());
    String fullNameDummyAttribute = IntegrationTestTools.getAttributeValue(accountWallyDefault.asObjectable(), new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceObject()), DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME));
    if (!"Bloodnose".equals(fullNameDummyAttribute) && !"Wally B. Feed".equals(fullNameDummyAttribute)) {
        AssertJUnit.fail("Wrong full name on default dummy resource: " + fullNameDummyAttribute);
    }
    assertShadowOperationalData(accountWallyDefault, SynchronizationSituationType.LINKED);
    assertShadowOperationalData(accountWallyDefault, SynchronizationSituationType.LINKED);
    assertDummyAccountAttribute(RESOURCE_DUMMY_GREEN_NAME, ACCOUNT_WALLY_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Plunder island");
    assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_WALLY_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Scabb Island");
    assertDummyAccountAttribute(null, ACCOUNT_WALLY_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Plunder island");
    assertLinks(userWally, 3);
    assertLinked(userWally, accountWallyGreen);
    assertLinked(userWally, accountWallyBlue);
    assertLinked(userWally, accountWallyDefault);
    assertUsers(7 + getNumberOfExtraDummyUsers());
    notificationManager.setDisabled(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 100 with ShadowType

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

the class AbstractSynchronizationStoryTest method test110AddDummyGreenAccountMancomb.

@Test
public void test110AddDummyGreenAccountMancomb() throws Exception {
    final String TEST_NAME = "test110AddDummyGreenAccountMancomb";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(5);
    DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    account.setEnabled(true);
    account.setValidFrom(ACCOUNT_MANCOMB_VALID_FROM_DATE);
    account.setValidTo(ACCOUNT_MANCOMB_VALID_TO_DATE);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
    /// WHEN
    TestUtil.displayWhen(TEST_NAME);
    dummyResourceGreen.addAccount(account);
    waitForSyncTaskNextRunAssertSuccess(resourceDummyGreen);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyGreen);
    display("Account mancomb", accountMancomb);
    assertNotNull("No mancomb account shadow", accountMancomb);
    assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_GREEN_OID, accountMancomb.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountMancomb, SynchronizationSituationType.LINKED);
    assertValidFrom(accountMancomb, ACCOUNT_MANCOMB_VALID_FROM_DATE);
    assertValidTo(accountMancomb, ACCOUNT_MANCOMB_VALID_TO_DATE);
    PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    display("User mancomb", userMancomb);
    assertNotNull("User mancomb was not created", userMancomb);
    assertLinks(userMancomb, 1);
    assertAdministrativeStatusEnabled(userMancomb);
    assertValidFrom(userMancomb, ACCOUNT_MANCOMB_VALID_FROM_DATE);
    assertValidTo(userMancomb, ACCOUNT_MANCOMB_VALID_TO_DATE);
    assertLinked(userMancomb, accountMancomb);
    assertUsers(6);
    // notifications
    notificationManager.setDisabled(true);
//        checkDummyTransportMessages("userPasswordNotifier", 1);                     // password is generated by mapping (if there's none)
//        checkDummyTransportMessages("accountPasswordNotifier", 1);                  // account password is then set
//        checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
//        checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
//        checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 0);        // account itself is not added (only the shadow is!)
//        checkDummyTransportMessages("simpleUserNotifier", 1);
//        checkDummyTransportMessages("simpleUserNotifier-ADD", 1);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)903 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)728 Test (org.testng.annotations.Test)693 Task (com.evolveum.midpoint.task.api.Task)600 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)398 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)170 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)154 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)153 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)129 QName (javax.xml.namespace.QName)123 PrismObject (com.evolveum.midpoint.prism.PrismObject)105 ArrayList (java.util.ArrayList)95 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)89 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)78 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)74 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)64 Entry (org.apache.directory.api.ldap.model.entry.Entry)61 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)60 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)55