Search in sources :

Example 71 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class TestMultiResource method test121JackTryDeleteAccount.

/**
	 * Try to delete Jack's default dummy account. As other provisioned accounts depends on it the
	 * operation should fail.
	 */
@Test
public void test121JackTryDeleteAccount() throws Exception {
    final String TEST_NAME = "test121JackTryDeleteAccount";
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    getDummyResource().resetBreakMode();
    // Clean up user
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    String accountJackDummyOid = getLinkRefOid(userJack, RESOURCE_DUMMY_OID);
    ObjectDelta<ShadowType> accountDelta = ObjectDelta.createDeleteDelta(ShadowType.class, accountJackDummyOid, prismContext);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(accountDelta);
    try {
        // WHEN
        modelService.executeChanges(deltas, null, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (PolicyViolationException e) {
        // This is expected
        display("Expected exception", e);
    }
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) TestRbac(com.evolveum.midpoint.model.intest.rbac.TestRbac) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractPasswordTest(com.evolveum.midpoint.model.intest.password.AbstractPasswordTest)

Example 72 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class TestMultiResource method test300AddAndAssignRelative.

@Test
public void test300AddAndAssignRelative() throws Exception {
    final String TEST_NAME = "test300AddAndAssignRelative";
    TestUtil.displayTestTile(TEST_NAME);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Add default dummy account to jack without assigning it.
    // In relative mode this account should shay untouched while we play with assignments and
    // unsassignements of other accounts
    PrismObject<ShadowType> account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE);
    ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
    PrismReferenceValue accountRefVal = new PrismReferenceValue();
    accountRefVal.setObject(account);
    ReferenceDelta accountDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
    userDelta.addModification(accountDelta);
    Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection) MiscUtil.createCollection(userDelta);
    modelService.executeChanges(deltas, null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after default dummy account add", userJack);
    assertUserJack(userJack);
    assertAccount(userJack, RESOURCE_DUMMY_OID);
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assignAccount(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    userJack = getUser(USER_JACK_OID);
    display("User after red dummy assignment", userJack);
    assertUserJack(userJack);
    assertAccount(userJack, RESOURCE_DUMMY_OID);
    assertAccount(userJack, RESOURCE_DUMMY_BLUE_OID);
    assertLinks(userJack, 2);
    String accountOid = getLinkRefOid(userJack, RESOURCE_DUMMY_BLUE_OID);
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    assertAccountShadowRepo(accountShadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyBlueType);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertAccountShadowModel(accountModel, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyBlueType);
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) Collection(java.util.Collection) TestRbac(com.evolveum.midpoint.model.intest.rbac.TestRbac) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractPasswordTest(com.evolveum.midpoint.model.intest.password.AbstractPasswordTest)

Example 73 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ReportCreateTaskHandler method saveReportOutputType.

private void saveReportOutputType(String filePath, ReportType reportType, Task task, OperationResult parentResult) throws Exception {
    String fileName = FilenameUtils.getBaseName(filePath);
    String reportOutputName = fileName + " - " + reportType.getExport().value();
    ReportOutputType reportOutputType = new ReportOutputType();
    prismContext.adopt(reportOutputType);
    reportOutputType.setFilePath(filePath);
    reportOutputType.setReportRef(MiscSchemaUtil.createObjectReference(reportType.getOid(), ReportType.COMPLEX_TYPE));
    reportOutputType.setName(new PolyStringType(reportOutputName));
    reportOutputType.setDescription(reportType.getDescription() + " - " + reportType.getExport().value());
    reportOutputType.setExportType(reportType.getExport());
    ObjectDelta<ReportOutputType> objectDelta = null;
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    OperationResult subResult = null;
    objectDelta = ObjectDelta.createAddDelta((PrismObject<ReportOutputType>) reportOutputType.asPrismObject());
    deltas.add(objectDelta);
    subResult = parentResult.createSubresult(ReportCreateTaskHandler.class.getName() + "createRepourtOutput");
    modelService.executeChanges(deltas, null, task, subResult);
    String outputOid = objectDelta.getOid();
    LOGGER.debug("Created report output with OID {}", outputOid);
    PrismProperty<String> outputOidProperty = prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(ReportConstants.REPORT_OUTPUT_OID_PROPERTY_NAME).instantiate();
    outputOidProperty.setRealValue(outputOid);
    task.setExtensionPropertyImmediate(outputOidProperty, subResult);
    subResult.computeStatus();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 74 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ReportWebService method createObjectListType.

private ObjectListType createObjectListType(Collection resultList) {
    if (resultList == null) {
        return new ObjectListType();
    }
    ObjectListType results = new ObjectListType();
    int skipped = 0;
    for (Object object : resultList) {
        if (object instanceof PrismObject) {
            results.getObject().add(((PrismObject<ObjectType>) object).asObjectable());
        } else if (object instanceof ObjectType) {
            results.getObject().add((ObjectType) object);
        } else {
            skipped++;
        }
    }
    if (skipped > 0) {
        LOGGER.warn("{} non-PrismObject data objects not returned, as these are not supported by ReportWebService yet", skipped);
    }
    return results;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)

Example 75 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method searchRoleByName.

protected RoleType searchRoleByName(String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (RoleType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)243 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)126 Test (org.testng.annotations.Test)97 Task (com.evolveum.midpoint.task.api.Task)82 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)68 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)55 ArrayList (java.util.ArrayList)51 Holder (javax.xml.ws.Holder)48 QName (javax.xml.namespace.QName)32 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)28 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)24 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)22