Search in sources :

Example 91 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestRbac method testJackUnassignRolePirateRelationNoPrivs.

public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception {
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    display("User jack before", userBefore);
    XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User jack after", userAfter);
    assertNoAssignments(userAfter);
    assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 92 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method test090UserModifyModifyResourceAssignmentValidity.

/**
     * User modification: modifying validity of single security-sensitive resource assignment.
     */
@Test(enabled = true)
public void test090UserModifyModifyResourceAssignmentValidity() throws Exception {
    TestUtil.displayTestTile(this, "test090UserModifyModifyResourceAssignmentValidity");
    login(userAdministrator);
    final XMLGregorianCalendar validFrom = XmlTypeConverter.createXMLGregorianCalendar(2015, 2, 25, 10, 0, 0);
    final XMLGregorianCalendar validTo = XmlTypeConverter.createXMLGregorianCalendar(2015, 3, 25, 10, 0, 0);
    executeTest("test090UserModifyModifyResourceAssignmentValidity", USER_JACK_OID, new TestDetails() {

        @Override
        int subtaskCount() {
            return 1;
        }

        @Override
        boolean immediate() {
            return false;
        }

        @Override
        boolean checkObjectOnSubtasks() {
            return true;
        }

        @Override
        boolean removeAssignmentsBeforeTest() {
            return false;
        }

        @Override
        public LensContext createModelContext(Task task, OperationResult result) throws Exception {
            LensContext<UserType> context = createUserLensContext();
            fillContextWithUser(context, USER_JACK_OID, result);
            UserType jack = context.getFocusContext().getObjectOld().asObjectable();
            modifyAssignmentValidity(context, jack, validFrom, validTo);
            return context;
        }

        @Override
        public void assertsAfterClockworkRun(Task rootTask, List<Task> wfSubtasks, OperationResult result) throws Exception {
            ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result);
            assertEquals("There are modifications left in primary focus delta", 0, taskModelContext.getFocusContext().getPrimaryDelta().getModifications().size());
            UserType jack = getUser(USER_JACK_OID).asObjectable();
            checkNoAssignmentValidity(jack);
        }

        @Override
        void assertsRootTaskFinishes(Task task, List<Task> subtasks, OperationResult result) throws Exception {
            assertAssignedResource(USER_JACK_OID, RESOURCE_DUMMY_OID, task, result);
            UserType jack = getUser(USER_JACK_OID).asObjectable();
            checkAssignmentValidity(jack, validFrom, validTo);
            checkDummyTransportMessages("simpleUserNotifier", 1);
            //checkWorkItemAuditRecords(createResultMap(ROLE_R1_OID, WorkflowResult.APPROVED));
            checkUserApprovers(USER_JACK_OID, Arrays.asList(DUMMYBOSS_OID), result);
        }

        @Override
        boolean decideOnApproval(String executionId) throws Exception {
            login(getUser(DUMMYBOSS_OID));
            return true;
        }
    });
}
Also used : ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) JAXBException(javax.xml.bind.JAXBException) Test(org.testng.annotations.Test)

Example 93 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method modifyAssignmentValidity.

protected void modifyAssignmentValidity(LensContext<UserType> context, UserType jack, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) throws SchemaException {
    assertEquals("jack's assignments", 1, jack.getAssignment().size());
    PrismContainerDefinition<ActivationType> activationDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).findContainerDefinition(new ItemPath(UserType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION));
    assertNotNull("no activationDef", activationDef);
    Long assignmentId = jack.getAssignment().get(0).getId();
    PrismPropertyDefinition<XMLGregorianCalendar> validFromDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_FROM);
    PropertyDelta<XMLGregorianCalendar> validFromDelta = new PropertyDelta<>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_FROM)), validFromDef, prismContext);
    validFromDelta.setValueToReplace(new PrismPropertyValue<>(validFrom));
    PrismPropertyDefinition<XMLGregorianCalendar> validToDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_TO);
    PropertyDelta<XMLGregorianCalendar> validToDelta = new PropertyDelta<>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_TO)), validToDef, prismContext);
    validToDelta.setValueToReplace(new PrismPropertyValue<>(validTo));
    ObjectDelta<UserType> userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext);
    userDelta.setOid(USER_JACK_OID);
    userDelta.addModification(validFromDelta);
    userDelta.addModification(validToDelta);
    addFocusDeltaToContext(context, userDelta);
}
Also used : NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 94 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method test070UserModifyAssignment.

@Test(enabled = true)
public void test070UserModifyAssignment() throws Exception {
    TestUtil.displayTestTile(this, "test070UserModifyAssignment");
    login(userAdministrator);
    removeAllAssignments(USER_JACK_OID, new OperationResult("dummy"));
    assignRoleRaw(USER_JACK_OID, ROLE_R1_OID);
    final XMLGregorianCalendar validFrom = XmlTypeConverter.createXMLGregorianCalendar(2015, 2, 25, 10, 0, 0);
    final XMLGregorianCalendar validTo = XmlTypeConverter.createXMLGregorianCalendar(2015, 3, 25, 10, 0, 0);
    executeTest("test070UserModifyAssignment", USER_JACK_OID, new TestDetails() {

        @Override
        int subtaskCount() {
            return 1;
        }

        @Override
        boolean immediate() {
            return false;
        }

        @Override
        boolean checkObjectOnSubtasks() {
            return true;
        }

        @Override
        boolean removeAssignmentsBeforeTest() {
            return false;
        }

        @Override
        public LensContext createModelContext(Task task, OperationResult result) throws Exception {
            LensContext<UserType> context = createUserLensContext();
            fillContextWithUser(context, USER_JACK_OID, result);
            UserType jack = context.getFocusContext().getObjectOld().asObjectable();
            modifyAssignmentValidity(context, jack, validFrom, validTo);
            return context;
        }

        @Override
        public void assertsAfterClockworkRun(Task rootTask, List<Task> wfSubtasks, OperationResult result) throws Exception {
            ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result);
            assertEquals("There are modifications left in primary focus delta", 0, taskModelContext.getFocusContext().getPrimaryDelta().getModifications().size());
            UserType jack = getUser(USER_JACK_OID).asObjectable();
            checkNoAssignmentValidity(jack);
        }

        @Override
        void assertsRootTaskFinishes(Task task, List<Task> subtasks, OperationResult result) throws Exception {
            UserType jack = getUser(USER_JACK_OID).asObjectable();
            checkAssignmentValidity(jack, validFrom, validTo);
        // TODO
        //checkDummyTransportMessages("simpleUserNotifier", 1);
        }

        @Override
        boolean decideOnApproval(String executionId) throws Exception {
            login(getUser(R1BOSS_OID));
            return true;
        }
    });
}
Also used : ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) JAXBException(javax.xml.bind.JAXBException) Test(org.testng.annotations.Test)

Example 95 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class WfTask method setProcessInstanceEndTimestamp.

public void setProcessInstanceEndTimestamp() throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
    XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar(new Date());
    task.addModification(DeltaBuilder.deltaFor(TaskType.class, getPrismContext()).item(F_WORKFLOW_CONTEXT, F_END_TIMESTAMP).replace(now).asItemDelta());
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)336 Test (org.testng.annotations.Test)159 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)130 Task (com.evolveum.midpoint.task.api.Task)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)52 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)44 Date (java.util.Date)36 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)32 ArrayList (java.util.ArrayList)32 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)31 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 AbstractSynchronizationStoryTest (com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 GregorianCalendar (java.util.GregorianCalendar)18 QName (javax.xml.namespace.QName)18 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 Duration (javax.xml.datatype.Duration)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14