Search in sources :

Example 26 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class RRole method toJAXB.

@Override
public RoleType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    RoleType object = new RoleType();
    RRole.copyToJAXB(this, object, prismContext, options);
    RUtil.revive(object, prismContext);
    return object;
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)

Example 27 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test810SyncAddGroupMonkeys.

@Test
public void test810SyncAddGroupMonkeys() throws Exception {
    final String TEST_NAME = "test810SyncAddGroupMonkeys";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long tsStart = System.currentTimeMillis();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    if (needsGroupFakeMemeberEntry()) {
        addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix());
    } else {
        addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION);
    }
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<RoleType> role = findObjectByName(RoleType.class, GROUP_MONKEYS_CN);
    display("Role", role);
    assertNotNull("no role " + GROUP_MONKEYS_CN, role);
    PrismAsserts.assertPropertyValue(role, RoleType.F_DESCRIPTION, GROUP_MONKEYS_DESCRIPTION);
    assertNotNull("No role " + GROUP_MONKEYS_CN + " created", role);
    assertStepSyncToken(getSyncTaskOid(), 3, tsStart, tsEnd);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 28 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class TestDeputy method test170AddRoleDrinker.

@Test
public void test170AddRoleDrinker() throws Exception {
    final String TEST_NAME = "test170AssignJackRoleDrinker";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDeputy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_DRINKER_FILE);
    display("Adding role", role);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    addObject(role, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<RoleType> roleAfter = getObject(RoleType.class, ROLE_DRINKER_OID);
    display("Role after", roleAfter);
    assertAssignedOrg(roleAfter, ORG_MINISTRY_OF_RUM_OID);
    assertHasOrg(roleAfter, ORG_MINISTRY_OF_RUM_OID);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestValidityRecomputeTask(com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 29 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class ModifyTest method test100ModifyUserAddRole.

@Test
public void test100ModifyUserAddRole() throws Exception {
    final String TEST_NAME = "test100ModifyUserAddRole";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult parentResult = new OperationResult("Modify user -> add roles");
    String userToModifyOid = "f65963e3-9d47-4b18-aaf3-bfc98bdfa000";
    PrismObject<ResourceType> csvResource = prismContext.parseObject(new File(TEST_DIR + "/resource-csv.xml"));
    repositoryService.addObject(csvResource, null, parentResult);
    PrismObject<ResourceType> openDjResource = prismContext.parseObject(new File(TEST_DIR + "/resource-opendj.xml"));
    repositoryService.addObject(openDjResource, null, parentResult);
    PrismObject<UserType> user = prismContext.parseObject(new File(TEST_DIR + "/user.xml"));
    repositoryService.addObject(user, null, parentResult);
    PrismObject<RoleType> roleCsv = prismContext.parseObject(new File(TEST_DIR + "/role-csv.xml"));
    repositoryService.addObject(roleCsv, null, parentResult);
    String ldapRoleOid = "12345678-d34d-b33f-f00d-987987987988";
    PrismObject<RoleType> roleLdap = prismContext.parseObject(new File(TEST_DIR + "/role-ldap.xml"));
    repositoryService.addObject(roleLdap, null, parentResult);
    RoleType ldapRole = repositoryService.getObject(RoleType.class, ldapRoleOid, null, parentResult).asObjectable();
    assertEquals("Expected that the role has one approver.", 1, ldapRole.getApproverRef().size());
    assertEquals("Actual approved not equals to expected one.", userToModifyOid, ldapRole.getApproverRef().get(0).getOid());
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR + "/modify-user-add-roles.xml"), ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
    repositoryService.modifyObject(UserType.class, userToModifyOid, delta.getModifications(), getModifyOptions(), parentResult);
    UserType modifiedUser = repositoryService.getObject(UserType.class, userToModifyOid, null, parentResult).asObjectable();
    assertEquals("wrong number of assignments", 3, modifiedUser.getAssignment().size());
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) Test(org.testng.annotations.Test)

Example 30 with RoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType in project midpoint by Evolveum.

the class ModifyTest method test150ModifyRoleAddInducements.

@Test
public void test150ModifyRoleAddInducements() throws Exception {
    final String TEST_NAME = "test150ModifyRoleAddInducements";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = new OperationResult(TEST_NAME);
    File roleFile = new File(TEST_DIR, "role-modify.xml");
    //add first user
    PrismObject<RoleType> role = prismContext.parseObject(roleFile);
    String oid = repositoryService.addObject(role, null, result);
    //modify second user name to "existingName"
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "role-modify-change.xml"), ObjectModificationType.COMPLEX_TYPE);
    modification.setOid(oid);
    Collection<? extends ItemDelta> deltas = DeltaConvertor.toModifications(modification, RoleType.class, prismContext);
    repositoryService.modifyObject(RoleType.class, oid, deltas, getModifyOptions(), result);
    result.recomputeStatus();
    AssertJUnit.assertTrue(result.isSuccess());
    role = repositoryService.getObject(RoleType.class, oid, null, result);
    result.recomputeStatus();
    AssertJUnit.assertTrue(result.isSuccess());
    PrismContainer container = role.findContainer(RoleType.F_INDUCEMENT);
    assertEquals(2, container.size());
    AssertJUnit.assertNotNull(container.getValue(2L));
    AssertJUnit.assertNotNull(container.getValue(3L));
    // modify role once more to check version progress
    String version = role.getVersion();
    repositoryService.modifyObject(RoleType.class, oid, new ArrayList<ItemDelta>(), getModifyOptions(), result);
    result.recomputeStatus();
    AssertJUnit.assertTrue(result.isSuccess());
    role = repositoryService.getObject(RoleType.class, oid, null, result);
    result.recomputeStatus();
    AssertJUnit.assertTrue(result.isSuccess());
    if (RepoModifyOptions.isExecuteIfNoChanges(getModifyOptions())) {
        SqlRepoTestUtil.assertVersionProgress(version, role.getVersion());
    } else {
        assertEquals("Version has changed", version, role.getVersion());
    }
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) File(java.io.File) 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