use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractSecurityTest method test000Sanity.
@Test
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
TestUtil.displayTestTile(this, TEST_NAME);
assertLoggedInUser(USER_ADMINISTRATOR_USERNAME);
// WHEN
PrismObject<RoleType> roleSelf = getRole(ROLE_SELF_OID);
// THEN
display("Role self", roleSelf);
List<AuthorizationType> authorizations = roleSelf.asObjectable().getAuthorization();
assertEquals("Wrong number of authorizations", 2, authorizations.size());
AuthorizationType authRead = findAutz(authorizations, ModelAuthorizationAction.READ.getUrl());
assertEquals("Wrong action in authorization", ModelAuthorizationAction.READ.getUrl(), authRead.getAction().get(0));
List<OwnedObjectSelectorType> objectSpecs = authRead.getObject();
assertEquals("Wrong number of object specs in authorization", 1, objectSpecs.size());
SubjectedObjectSelectorType objectSpec = objectSpecs.get(0);
List<SpecialObjectSpecificationType> specials = objectSpec.getSpecial();
assertEquals("Wrong number of specials in object specs in authorization", 1, specials.size());
SpecialObjectSpecificationType special = specials.get(0);
assertEquals("Wrong special in object specs in authorization", SpecialObjectSpecificationType.SELF, special);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.
protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
if (task == null) {
task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget");
}
OperationResult result = task.getResult();
AssignmentType inducement = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(targetOid);
inducement.setTargetRef(targetRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT)), prismContext, inducement);
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcileAffected(reconcileAffected);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result);
result.computeStatus();
if (reconcileAffected) {
TestUtil.assertInProgressOrSuccess(result);
} else {
TestUtil.assertSuccess(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddConstruction.
protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction");
OperationResult result = task.getResult();
ConstructionType construction = new ConstructionType();
ObjectReferenceType resourceRedRef = new ObjectReferenceType();
resourceRedRef.setOid(resourceOid);
construction.setResourceRef(resourceRedRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(inducementId), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), prismContext, construction);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractTestLifecycle method test010CreateRolePirate.
@Test
public void test010CreateRolePirate() throws Exception {
final String TEST_NAME = "test010CreateRolePirate";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
RoleType pirate = new RoleType(prismContext);
pirate.setName(PolyStringType.fromOrig("pirate"));
if (approveObjectAdd()) {
createObject(TEST_NAME, pirate, false, true, userLead1Oid);
rolePirateOid = searchObjectByName(RoleType.class, "pirate").getOid();
} else {
repoAddObject(pirate.asPrismObject(), result);
rolePirateOid = pirate.getOid();
}
PrismReferenceValue pirateOwner = new PrismReferenceValue(rolePirateOid, RoleType.COMPLEX_TYPE);
pirateOwner.setRelation(SchemaConstants.ORG_OWNER);
executeChanges((ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(pirateOwner, prismContext)).asObjectDelta(userPirateOwnerOid), null, task, result);
display("Pirate role", getRole(rolePirateOid));
display("Pirate owner", getUser(userPirateOwnerOid));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.
the class AbstractTestLifecycle method test100ModifyRolePirateDescription.
@Test
public void test100ModifyRolePirateDescription() throws Exception {
final String TEST_NAME = "test100ModifyRolePirateDescription";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
ObjectDelta<RoleType> descriptionDelta = (ObjectDelta<RoleType>) DeltaBuilder.deltaFor(RoleType.class, prismContext).item(RoleType.F_DESCRIPTION).replace("Bloody pirate").asObjectDelta(rolePirateOid);
ObjectDelta<RoleType> delta0 = ObjectDelta.createModifyDelta(rolePirateOid, Collections.emptyList(), RoleType.class, prismContext);
//noinspection UnnecessaryLocalVariable
ObjectDelta<RoleType> delta1 = descriptionDelta;
ExpectedTask expectedTask = new ExpectedTask(null, "Modification of pirate");
ExpectedWorkItem expectedWorkItem = new ExpectedWorkItem(userPirateOwnerOid, null, expectedTask);
modifyObject(TEST_NAME, descriptionDelta, delta0, delta1, false, true, userPirateOwnerOid, Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem), () -> {
}, () -> assertNull("Description is modified", getRoleSimple(rolePirateOid).getDescription()), () -> assertEquals("Description was NOT modified", "Bloody pirate", getRoleSimple(rolePirateOid).getDescription()));
}
Aggregations