Search in sources :

Example 36 with SelectorQualifiedGetOptionsType

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

the class TestSanityLegacy 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 37 with SelectorQualifiedGetOptionsType

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

the class TestSanityLegacy method test031EnableUser.

/**
     * Try to enable user after it has been disabled. As the user has an account, the account should be enabled as well.
     */
@Test
public void test031EnableUser() throws Exception {
    final String TEST_NAME = "test031EnableUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ACTIVATION_ENABLE_FILENAME, ObjectDeltaType.class);
    assertNoRepoCache();
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    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> uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    display("repo user", repoUser);
    // Check if nothing else was modified
    PrismAsserts.assertEqualsPolyString("wrong repo fullName", "Cpt. Jack Sparrow", repoUser.getFullName());
    PrismAsserts.assertEqualsPolyString("wrong repo locality", "somewhere", repoUser.getLocality());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
    assertEquals(1, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUser, accountRef.getOid().equals(accountShadowOidOpendj));
    }
    // 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);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repo shadow", repoShadowType);
    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);
    // 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
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder);
    // THEN
    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, SchemaConstants.ICFS_UID);
    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 enabled in the shadow", ActivationStatusType.ENABLED, modelShadow.getActivation().getAdministrativeStatus());
    // Check if LDAP account was updated
    Entry entry = openDJController.searchAndAssertByEntryUuid(uid);
    assertOpenDJAccountJack(entry, "jack");
    // The value of ds-pwp-account-disabled should have been removed
    String pwpAccountDisabled = OpenDJController.getAttributeValue(entry, "ds-pwp-account-disabled");
    System.out.println("ds-pwp-account-disabled after change: " + pwpAccountDisabled);
    assertTrue("LDAP account was not enabled", openDJController.isAccountEnabled(entry));
}
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) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) 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 38 with SelectorQualifiedGetOptionsType

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

the class AbstractWebserviceTest method cleanObjects.

private <O extends ObjectType> void cleanObjects(Class<O> type, boolean raw, String... protectedOids) throws FaultMessage {
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    SelectorQualifiedGetOptionsType rootOpts = null;
    ModelExecuteOptionsType execOpts = null;
    if (raw) {
        rootOpts = ModelClientUtil.createRootGetOptions(ModelClientUtil.createRawGetOption());
        execOpts = ModelClientUtil.createRawExecuteOption();
    }
    modelPort.searchObjects(getTypeQName(type), null, rootOpts, objectListHolder, resultHolder);
    List<String> protectedOidList = Arrays.asList(protectedOids);
    ObjectListType objectList = objectListHolder.value;
    for (ObjectType object : objectList.getObject()) {
        if (!protectedOidList.contains(object.getOid())) {
            display("Deleting " + type.getSimpleName() + " " + ModelClientUtil.toString(object));
            deleteObject(type, object.getOid(), execOpts);
        }
    }
}
Also used : Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType)

Example 39 with SelectorQualifiedGetOptionsType

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

the class ModelClientUtil method createRootGetOptions.

public static SelectorQualifiedGetOptionsType createRootGetOptions(GetOperationOptionsType opt) {
    SelectorQualifiedGetOptionsType rootOpts = new SelectorQualifiedGetOptionsType();
    SelectorQualifiedGetOptionType selOpt = new SelectorQualifiedGetOptionType();
    selOpt.setOptions(opt);
    rootOpts.getOption().add(selOpt);
    return rootOpts;
}
Also used : SelectorQualifiedGetOptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 40 with SelectorQualifiedGetOptionsType

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

the class ModelWebServiceTest method getNonexistingObject.

@Test(expectedExceptions = FaultMessage.class)
public void getNonexistingObject() throws FaultMessage, ObjectNotFoundException, SchemaException, IOException, JAXBException {
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        final String oid = "abababab-abab-abab-abab-000000000001";
        when(repositoryService.getObject(any(Class.class), eq(oid), any(Collection.class), any(OperationResult.class))).thenThrow(new ObjectNotFoundException("Object with oid '" + oid + "' not found."));
        modelService.getObject(UserType.COMPLEX_TYPE, oid, new SelectorQualifiedGetOptionsType(), new Holder<ObjectType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertObjectNotFoundFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("get must fail");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test)

Aggregations

SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)39 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)6 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)5 QName (javax.xml.namespace.QName)5