Search in sources :

Example 51 with RoleType

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);
}
Also used : SubjectedObjectSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubjectedObjectSelectorType) OwnedObjectSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.OwnedObjectSelectorType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) SpecialObjectSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SpecialObjectSpecificationType) AuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 52 with RoleType

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);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 53 with RoleType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 54 with RoleType

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));
}
Also used : ExpectedTask(com.evolveum.midpoint.wf.impl.policy.ExpectedTask) Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 55 with RoleType

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()));
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ExpectedWorkItem(com.evolveum.midpoint.wf.impl.policy.ExpectedWorkItem) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ExpectedTask(com.evolveum.midpoint.wf.impl.policy.ExpectedTask) Test(org.testng.annotations.Test)

Aggregations

RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)67 Test (org.testng.annotations.Test)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)39 Task (com.evolveum.midpoint.task.api.Task)34 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)18 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)9 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)8 AbstractRoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType)8 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)8 QName (javax.xml.namespace.QName)7 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)5 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)5 File (java.io.File)5 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4