Search in sources :

Example 26 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractAdLdapTest method test105SeachPiratesByCn.

@Test
public void test105SeachPiratesByCn() throws Exception {
    final String TEST_NAME = "test105SeachPiratesByCn";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext);
    ObjectQueryUtil.filterAnd(query.getFilter(), createAttributeFilter("cn", GROUP_PIRATES_NAME));
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected search result: " + shadows, 1, shadows.size());
    PrismObject<ShadowType> shadow = shadows.get(0);
    display("Shadow", shadow);
    groupPiratesOid = shadow.getOid();
    assertConnectorOperationIncrement(1);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Example 27 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractEDirTest method test800JackLockoutExpires.

// Wait until the lockout of Jack expires, check status
@Test
public void test800JackLockoutExpires() throws Exception {
    final String TEST_NAME = "test800JackLockoutExpires";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long now = System.currentTimeMillis();
    long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS * 1000;
    if (now < lockoutExpires) {
        display("Sleeping for " + (lockoutExpires - now) + "ms (waiting for lockout expiration)");
        Thread.sleep(lockoutExpires - now);
    }
    now = System.currentTimeMillis();
    display("Time is now " + now);
    ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected search result: " + shadows, 1, shadows.size());
    PrismObject<ShadowType> shadow = shadows.get(0);
    display("Shadow", shadow);
    assertAccountShadow(shadow, toAccountDn(ACCOUNT_JACK_UID));
    assertShadowLockout(shadow, LockoutStatusType.NORMAL);
    assertConnectorOperationIncrement(1);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 28 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractEDirTest method test820JackLockoutAndUnlock.

@Test
public void test820JackLockoutAndUnlock() throws Exception {
    final String TEST_NAME = "test820JackLockoutAndUnlock";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    makeBadLoginAttempt(ACCOUNT_JACK_UID);
    makeBadLoginAttempt(ACCOUNT_JACK_UID);
    makeBadLoginAttempt(ACCOUNT_JACK_UID);
    makeBadLoginAttempt(ACCOUNT_JACK_UID);
    jackLockoutTimestamp = System.currentTimeMillis();
    ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID);
    // precondition
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected search result: " + shadows, 1, shadows.size());
    PrismObject<ShadowType> shadowLocked = shadows.get(0);
    display("Locked shadow", shadowLocked);
    assertAccountShadow(shadowLocked, toAccountDn(ACCOUNT_JACK_UID));
    assertShadowLockout(shadowLocked, LockoutStatusType.LOCKED);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyObjectReplaceProperty(ShadowType.class, shadowLocked.getOid(), new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), task, result, LockoutStatusType.NORMAL);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertConnectorOperationIncrement(1);
    assertConnectorSimulatedPagingSearchIncrement(0);
    PrismObject<ShadowType> shadowAfter = getObject(ShadowType.class, shadowLocked.getOid());
    display("Shadow after", shadowAfter);
    assertAccountShadow(shadowAfter, toAccountDn(ACCOUNT_JACK_UID));
    assertShadowLockout(shadowAfter, LockoutStatusType.NORMAL);
    assertLdapPassword(ACCOUNT_JACK_UID, ACCOUNT_JACK_PASSWORD);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 29 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractEDirTest method test105SeachPiratesByCn.

@Test
public void test105SeachPiratesByCn() throws Exception {
    final String TEST_NAME = "test105SeachPiratesByCn";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext);
    ObjectQueryUtil.filterAnd(query.getFilter(), createAttributeFilter("cn", GROUP_PIRATES_NAME));
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected search result: " + shadows, 1, shadows.size());
    PrismObject<ShadowType> shadow = shadows.get(0);
    display("Shadow", shadow);
    groupPiratesOid = shadow.getOid();
    assertConnectorOperationIncrement(2);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 30 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractEDirTest method test100SeachJackByLdapUid.

@Test
public void test100SeachJackByLdapUid() throws Exception {
    final String TEST_NAME = "test100SeachJackByLdapUid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Unexpected search result: " + shadows, 1, shadows.size());
    PrismObject<ShadowType> shadow = shadows.get(0);
    display("Shadow", shadow);
    assertAccountShadow(shadow, toAccountDn(ACCOUNT_JACK_UID));
    assertShadowLockout(shadow, LockoutStatusType.NORMAL);
    jackAccountOid = shadow.getOid();
    assertNotNull("Null OID in " + shadow, jackAccountOid);
    assertConnectorOperationIncrement(2);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)39 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)39 PrismObject (com.evolveum.midpoint.prism.PrismObject)37 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)37 Task (com.evolveum.midpoint.task.api.Task)36 Test (org.testng.annotations.Test)34 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)19 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)9 QName (javax.xml.namespace.QName)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 GenericConnectorException (com.evolveum.midpoint.provisioning.api.GenericConnectorException)3 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)3 ProvisioningUtil (com.evolveum.midpoint.provisioning.util.ProvisioningUtil)3 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)3 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)3 InternalsConfig (com.evolveum.midpoint.schema.internals.InternalsConfig)3