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);
}
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;
}
});
}
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);
}
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;
}
});
}
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());
}
Aggregations