use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestRbac method test814ModifyRoleImmutableDescriptionGlobalIdentifier.
/**
* This should go well again. The constraint is related to modification of description, not identifier.
*/
@Test
public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Exception {
final String TEST_NAME = "test814ModifyRoleImmutableDescriptionGlobalIdentifier";
TestUtil.displayTestTile(this, TEST_NAME);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
final String NEW_VALUE = "whatever";
modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_IDENTIFIER, task, result, NEW_VALUE);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID);
display("Role after", roleAfter);
assertEquals("Wrong new identifier value", NEW_VALUE, roleAfter.asObjectable().getIdentifier());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class TestRecomputeTask method test100RecomputeAll.
@Test
public void test100RecomputeAll() throws Exception {
final String TEST_NAME = "test100RecomputeAll";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// Preconditions
assertUsers(5);
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME);
// Do some ordinary operations
assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result);
assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result);
addObject(USER_HERMAN_FILE);
assignRole(USER_HERMAN_OID, ROLE_JUDGE_OID, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
// Now do something evil
// change definition of role "pirate". midPoint will not recompute automatically
// the recompute task should do it
// One simple change
modifyRoleAddConstruction(ROLE_JUDGE_OID, 1111L, RESOURCE_DUMMY_RED_OID);
// More complicated change
PrismObject<RoleType> rolePirate = modelService.getObject(RoleType.class, ROLE_PIRATE_OID, null, task, result);
ItemPath attrItemPath = new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(1111L), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION), new IdItemPathSegment(60004L), new NameItemPathSegment(ConstructionType.F_ATTRIBUTE));
PrismProperty<ResourceAttributeDefinitionType> attributeProperty = rolePirate.findProperty(attrItemPath);
assertNotNull("No attribute property in " + rolePirate);
PrismPropertyValue<ResourceAttributeDefinitionType> oldAttrPVal = null;
for (PrismPropertyValue<ResourceAttributeDefinitionType> pval : attributeProperty.getValues()) {
ResourceAttributeDefinitionType attrType = pval.getValue();
if (ItemPathUtil.getOnlySegmentQName(attrType.getRef()).getLocalPart().equals(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME)) {
oldAttrPVal = pval;
}
}
assertNotNull("Definition for weapon attribute not found in " + rolePirate);
PrismPropertyValue<ResourceAttributeDefinitionType> newAttrPVal = oldAttrPVal.clone();
JAXBElement<?> cutlassExpressionEvalJaxbElement = newAttrPVal.getValue().getOutbound().getExpression().getExpressionEvaluator().get(0);
RawType cutlassValueEvaluator = (RawType) cutlassExpressionEvalJaxbElement.getValue();
RawType daggerValueEvaluator = new RawType(new PrimitiveXNode<String>("dagger"), prismContext);
JAXBElement<?> daggerExpressionEvalJaxbElement = new JAXBElement<Object>(SchemaConstants.C_VALUE, Object.class, daggerValueEvaluator);
newAttrPVal.getValue().getOutbound().getExpression().getExpressionEvaluator().add(daggerExpressionEvalJaxbElement);
newAttrPVal.getValue().getOutbound().setStrength(MappingStrengthType.STRONG);
ObjectDelta<RoleType> rolePirateDelta = ObjectDelta.createModificationDeleteProperty(RoleType.class, ROLE_PIRATE_OID, attrItemPath, prismContext, oldAttrPVal.getValue());
IntegrationTestTools.displayJaxb("AAAAAAAAAAA", newAttrPVal.getValue(), ConstructionType.F_ATTRIBUTE);
display("BBBBBB", newAttrPVal.getValue().toString());
rolePirateDelta.addModificationAddProperty(attrItemPath, newAttrPVal.getValue());
display("Role pirate delta", rolePirateDelta);
modelService.executeChanges(MiscSchemaUtil.createCollection(rolePirateDelta), null, task, result);
displayRoles(task, result);
assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack (before)", userJack);
assertDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME);
result.computeStatus();
TestUtil.assertSuccess(result);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(TASK_USER_RECOMPUTE_FILE);
dummyAuditService.clear();
waitForTaskStart(TASK_USER_RECOMPUTE_OID, false);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskFinish(TASK_USER_RECOMPUTE_OID, true, 40000);
// THEN
TestUtil.displayThen(TEST_NAME);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after recompute", users);
assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
userJack = getUser(USER_JACK_OID);
display("User jack (after)", userJack);
assertNoDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
assertUsers(6);
// Check audit
display("Audit", dummyAuditService);
List<AuditEventRecord> auditRecords = dummyAuditService.getRecords();
int i = 0;
int modifications = 0;
for (; i < (auditRecords.size() - 1); i += 2) {
AuditEventRecord requestRecord = auditRecords.get(i);
assertNotNull("No request audit record (" + i + ")", requestRecord);
assertEquals("Got this instead of request audit record (" + i + "): " + requestRecord, AuditEventStage.REQUEST, requestRecord.getEventStage());
assertTrue("Unexpected delta in request audit record " + requestRecord, requestRecord.getDeltas() == null || requestRecord.getDeltas().isEmpty());
AuditEventRecord executionRecord = auditRecords.get(i + 1);
assertNotNull("No execution audit record (" + i + ")", executionRecord);
assertEquals("Got this instead of execution audit record (" + i + "): " + executionRecord, AuditEventStage.EXECUTION, executionRecord.getEventStage());
assertTrue("Empty deltas in execution audit record " + executionRecord, executionRecord.getDeltas() != null && !executionRecord.getDeltas().isEmpty());
modifications++;
// check next records
while (i < (auditRecords.size() - 2)) {
AuditEventRecord nextRecord = auditRecords.get(i + 2);
if (nextRecord.getEventStage() == AuditEventStage.EXECUTION) {
// more than one execution record is OK
i++;
} else {
break;
}
}
}
assertEquals("Unexpected number of audit modifications", 6, modifications);
deleteObject(TaskType.class, TASK_USER_RECOMPUTE_OID, task, result);
}
Aggregations