Search in sources :

Example 1 with RefFilter

use of com.evolveum.midpoint.prism.query.RefFilter in project midpoint by Evolveum.

the class PrismAsserts method assertRefFilter.

public static void assertRefFilter(ObjectFilter objectFilter, QName expectedFilterDef, QName expectedTypeName, ItemPath path) {
    assertEquals("Wrong filter class", RefFilter.class, objectFilter.getClass());
    RefFilter filter = (RefFilter) objectFilter;
    assertEquals("Wrong filter definition element name", expectedFilterDef, filter.getDefinition().getName());
    assertEquals("Wrong filter definition type", expectedTypeName, filter.getDefinition().getTypeName());
    assertPathEquivalent("Wrong filter path", path, filter.getFullPath());
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter)

Example 2 with RefFilter

use of com.evolveum.midpoint.prism.query.RefFilter in project midpoint by Evolveum.

the class TestFilterExpression method test210EvaluateExpressionLinkRefDefaultsVal.

@Test
public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception {
    final String TEST_NAME = "test210EvaluateExpressionLinkRefDefaultsVal";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result);
    RefFilter refFilter = (RefFilter) filter;
    assertEquals("Wrong number of values in filter: " + refFilter.getValues(), 1, refFilter.getValues().size());
    executeFilter(filter, 1, task, result);
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 3 with RefFilter

use of com.evolveum.midpoint.prism.query.RefFilter in project midpoint by Evolveum.

the class TestFilterExpression method test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal.

@Test
public void test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal() throws Exception {
    final String TEST_NAME = "test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-object-reference-type-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result);
    RefFilter refFilter = (RefFilter) filter;
    assertEquals("Wrong number of values in filter: " + refFilter.getValues(), 1, refFilter.getValues().size());
    executeFilter(filter, 1, task, result);
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 4 with RefFilter

use of com.evolveum.midpoint.prism.query.RefFilter in project midpoint by Evolveum.

the class TestFilterExpression method test200EvaluateExpressionLinkRefDefaultsNull.

@Test
public void test200EvaluateExpressionLinkRefDefaultsNull() throws Exception {
    final String TEST_NAME = "test200EvaluateExpressionLinkRefDefaultsNull";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", null, RefFilter.class, task, result);
    RefFilter refFilter = (RefFilter) filter;
    AssertJUnit.assertNull("Expected NO values in filter, but found " + refFilter.getValues(), refFilter.getValues());
    executeFilter(filter, 2, task, result);
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 5 with RefFilter

use of com.evolveum.midpoint.prism.query.RefFilter in project midpoint by Evolveum.

the class TestSecurityBasic method test290AutzJackRoleOwnerAssign.

@Test
public void test290AutzJackRoleOwnerAssign() throws Exception {
    final String TEST_NAME = "test290AutzJackRoleOwnerAssign";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    cleanupAutzTest(USER_JACK_OID);
    assignRole(USER_JACK_OID, ROLE_ROLE_OWNER_ASSIGN_OID);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    login(USER_JACK_USERNAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assertReadAllow(NUMBER_OF_ALL_USERS + 1);
    assertAddDeny();
    assertModifyDeny();
    assertDeleteDeny();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertAssignments(user, 2);
    assertAssignedRole(user, ROLE_ROLE_OWNER_ASSIGN_OID);
    assertAllow("assign application role 1 to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result));
    user = getUser(USER_JACK_OID);
    assertAssignments(user, 3);
    assertAssignedRole(user, ROLE_APPLICATION_1_OID);
    assertDeny("assign application role 2 to jack", new Attempt() {

        @Override
        public void run(Task task, OperationResult result) throws Exception {
            assignRole(USER_JACK_OID, ROLE_APPLICATION_2_OID, task, result);
        }
    });
    assertAllow("unassign application role 1 from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result));
    user = getUser(USER_JACK_OID);
    assertAssignments(user, 2);
    RoleSelectionSpecification spec = getAssignableRoleSpecification(getUser(USER_JACK_OID));
    assertRoleTypes(spec);
    assertFilter(spec.getFilter(), TypeFilter.class);
    assertEquals("Wrong type filter type", RoleType.COMPLEX_TYPE, ((TypeFilter) spec.getFilter()).getType());
    ObjectFilter subfilter = ((TypeFilter) spec.getFilter()).getFilter();
    assertFilter(subfilter, RefFilter.class);
    assertEquals(1, ((RefFilter) subfilter).getValues().size());
    assertEquals("Wrong OID in ref filter", USER_JACK_OID, ((RefFilter) subfilter).getValues().get(0).getOid());
    assertGlobalStateUntouched();
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) Task(com.evolveum.midpoint.task.api.Task) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TypeFilter(com.evolveum.midpoint.prism.query.TypeFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) Test(org.testng.annotations.Test)

Aggregations

RefFilter (com.evolveum.midpoint.prism.query.RefFilter)6 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 Task (com.evolveum.midpoint.task.api.Task)5 Test (org.testng.annotations.Test)5 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)4 RoleSelectionSpecification (com.evolveum.midpoint.model.api.RoleSelectionSpecification)1 TypeFilter (com.evolveum.midpoint.prism.query.TypeFilter)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1