Search in sources :

Example 6 with SelectorQualifiedGetOptionsType

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

the class TestSanity method test004Capabilities.

@Test
public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
    TestUtil.displayTestTile("test004Capabilities");
    // GIVEN
    checkRepoOpenDjResource();
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder, resultHolder);
    ResourceType resource = (ResourceType) objectHolder.value;
    // THEN
    display("Resource", resource);
    assertNoRepoCache();
    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> capabilities = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", capabilities.isEmpty());
    for (Object capability : nativeCapabilities.getAny()) {
        System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    if (resource.getCapabilities() != null) {
        for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
            System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
        }
    }
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class);
    assertNotNull("password capability not present", capCred.getPassword());
    // Connector cannot do activation, this should be null
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities, ActivationCapabilityType.class);
    assertNull("Found activation capability while not expecting it", capAct);
    capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capAct);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) Holder(javax.xml.ws.Holder) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 7 with SelectorQualifiedGetOptionsType

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

the class TestSanity method searchAccountByOid.

private ShadowType searchAccountByOid(final String accountOid) throws Exception {
    OperationResultType resultType = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType);
    Holder<ObjectType> accountHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountOid, options, accountHolder, resultHolder);
    ObjectType object = accountHolder.value;
    TestUtil.assertSuccess("searchObjects has failed", resultHolder.value);
    assertNotNull("Account is null", object);
    if (!(object instanceof ShadowType)) {
        fail("Object is not account.");
    }
    ShadowType account = (ShadowType) object;
    assertEquals(accountOid, account.getOid());
    return account;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 8 with SelectorQualifiedGetOptionsType

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

the class TestSanity method test030DisableUser.

/**
     * Try to disable user. As the user has an account, the account should be disabled as well.
     */
@Test
public void test030DisableUser() throws Exception {
    final String TEST_NAME = "test030DisableUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ACTIVATION_DISABLE_FILENAME, ObjectDeltaType.class);
    Entry entry = openDJController.searchByUid("jack");
    assertOpenDJAccountJack(entry, "jack");
    String pwpAccountDisabled = OpenDJController.getAttributeValue(entry, "ds-pwp-account-disabled");
    display("ds-pwp-account-disabled before change", pwpAccountDisabled);
    assertTrue("LDAP account is not enabled (precondition)", openDJController.isAccountEnabled(entry));
    assertNoRepoCache();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    display("repository user", repoUser);
    UserType repoUserType = repoUser.asObjectable();
    // Check if nothing else was modified
    assertEqualsPolyString("wrong repo fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    assertEqualsPolyString("wrong repo locality", "somewhere", repoUserType.getLocality());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(2, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj) || accountRef.getOid().equals(accountShadowOidDerby));
    }
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    display("repo shadow", repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    AssertJUnit.assertNotNull(repoShadowType);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    entry = openDJController.searchAndAssertByEntryUuid(uid);
    assertOpenDJAccountJack(entry, "jack");
    pwpAccountDisabled = OpenDJController.getAttributeValue(entry, "ds-pwp-account-disabled");
    display("ds-pwp-account-disabled after change", pwpAccountDisabled);
    assertFalse("LDAP account was not disabled", openDJController.isAccountEnabled(entry));
    // Use getObject to test fetch of complete shadow
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    assertNoRepoCache();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoRepoCache();
    displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("getObject has failed", resultHolder.value);
    ShadowType modelShadow = (ShadowType) objectHolder.value;
    display("Shadow (model)", modelShadow);
    AssertJUnit.assertNotNull(modelShadow);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, modelShadow.getResourceRef().getOid());
    assertAttributeNotNull(modelShadow, getOpenDjPrimaryIdentifierQName());
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "uid", "jack");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "givenName", "Jack");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "sn", "Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "cn", "Cpt. Jack Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "displayName", "Cpt. Jack Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "l", "somewhere");
    assertNotNull("The account activation is null in the shadow", modelShadow.getActivation());
    assertNotNull("The account activation status was not present in shadow", modelShadow.getActivation().getAdministrativeStatus());
    assertEquals("The account was not disabled in the shadow", ActivationStatusType.DISABLED, modelShadow.getActivation().getAdministrativeStatus());
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 9 with SelectorQualifiedGetOptionsType

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

the class AbstractTestForExchangeConnector method listUsers.

protected Collection<UserType> listUsers() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // let's say we want to get first 3 users, sorted alphabetically by user name
    // holds search query + paging options
    QueryType queryType = new QueryType();
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);
    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 10 with SelectorQualifiedGetOptionsType

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

the class AbstractTestForExchangeConnector method listResources.

protected Collection<ResourceType> listResources() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ResourceType.class), null, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) Collection(java.util.Collection) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Aggregations

SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)34 Holder (javax.xml.ws.Holder)34 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)25 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)19 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 Test (org.testng.annotations.Test)14 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)12 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)9 Collection (java.util.Collection)9 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)8 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)8 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)7 SelectorQualifiedGetOptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionType)5 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)5 QName (javax.xml.namespace.QName)5