Search in sources :

Example 46 with RoleType

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

the class SearchShadowOwnerTest method searchShadowOwnerIsRole.

@Test
public void searchShadowOwnerIsRole() throws Exception {
    OperationResult result = new OperationResult("List owner");
    //look for account owner
    PrismObject<RoleType> role = repositoryService.searchShadowOwner("11223355", null, result);
    assertNotNull("No owner for account", role);
    PrismProperty name = role.findProperty(ObjectType.F_NAME);
    AssertJUnit.assertNotNull(name);
    String orig = ((PolyString) name.getRealValue()).getOrig();
    // there are two object which own tested shadow
    if ("Judge".equals(orig) || "lazyman vm".equals(orig)) {
        return;
    }
    AssertJUnit.fail("Unexpected object name for shadow owner '" + orig + "'");
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 47 with RoleType

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

the class Main method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    try {
        ModelPortType modelPort = createModelPort(args);
        SystemConfigurationType configurationType = getConfiguration(modelPort);
        System.out.println("Got system configuration");
        //			System.out.println(configurationType);
        UserType userAdministrator = searchUserByName(modelPort, "administrator");
        System.out.println("Got administrator user: " + userAdministrator.getOid());
        //			System.out.println(userAdministrator);
        RoleType sailorRole = searchRoleByName(modelPort, "Sailor");
        System.out.println("Got Sailor role");
        //			System.out.println(sailorRole);
        Collection<ResourceType> resources = listResources(modelPort);
        System.out.println("Resources (" + resources.size() + ")");
        //			dump(resources);
        Collection<UserType> users = listUsers(modelPort);
        System.out.println("Users (" + users.size() + ")");
        //            dump(users);
        Collection<TaskType> tasks = listTasks(modelPort);
        System.out.println("Tasks (" + tasks.size() + ")");
        //            dump(tasks);
        //            System.out.println("Next scheduled times: ");
        //            for (TaskType taskType : tasks) {
        //                System.out.println(" - " + getOrig(taskType.getName()) + ": " + taskType.getNextRunStartTimestamp());
        //            }
        String userGuybrushoid = createUserGuybrush(modelPort, sailorRole);
        System.out.println("Created user guybrush, OID: " + userGuybrushoid);
        UserType userGuybrush = getUser(modelPort, userGuybrushoid);
        System.out.println("Fetched user guybrush:");
        //			System.out.println(userGuybrush);
        System.out.println("Users fullName: " + ModelClientUtil.getOrig(userGuybrush.getFullName()));
        String userLeChuckOid = createUserFromSystemResource(modelPort, "user-lechuck.xml");
        System.out.println("Created user lechuck, OID: " + userLeChuckOid);
        changeUserPassword(modelPort, userGuybrushoid, "MIGHTYpirate");
        System.out.println("Changed user password");
        changeUserGivenName(modelPort, userLeChuckOid, "CHUCK");
        System.out.println("Changed user given name");
        assignRoles(modelPort, userGuybrushoid, ROLE_PIRATE_OID, ROLE_CAPTAIN_OID);
        System.out.println("Assigned roles");
        unAssignRoles(modelPort, userGuybrushoid, ROLE_CAPTAIN_OID);
        System.out.println("Unassigned roles");
        Collection<RoleType> roles = listRequestableRoles(modelPort);
        System.out.println("Found " + roles.size() + " requestable roles");
        //			System.out.println(roles);
        String seaSuperuserRole = createRoleFromSystemResource(modelPort, "role-sea-superuser.xml");
        System.out.println("Created role Sea Superuser, OID: " + seaSuperuserRole);
        assignRoles(modelPort, userLeChuckOid, seaSuperuserRole);
        System.out.println("Assigned role Sea Superuser to LeChuck");
        modifyRoleModifyInducement(modelPort, seaSuperuserRole);
        System.out.println("Modified role Sea Superuser - modified resource inducement");
        modifyRoleReplaceInducement(modelPort, seaSuperuserRole, 2, ROLE_CAPTAIN_OID);
        System.out.println("Modified role Sea Superuser - changed role inducement");
        reconcileUser(modelPort, userLeChuckOid);
        System.out.println("LeChuck reconciled.");
        // Uncomment the following lines if you want to see what midPoint really did
        // ... because deleting the user will delete also all the traces (except logs and audit of course).
        deleteUser(modelPort, userGuybrushoid);
        deleteUser(modelPort, userLeChuckOid);
        deleteRole(modelPort, seaSuperuserRole);
        System.out.println("Deleted user(s)");
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Example 48 with RoleType

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

the class AbstractLdapSynchronizationTest method test830AddGroupFools.

/**
	 * Add a new group. Check that this event is ignored.
	 */
@Test
public void test830AddGroupFools() throws Exception {
    final String TEST_NAME = "test830AddGroupFools";
    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);
    addLdapGroup(GROUP_FOOLS_CN, GROUP_FOOLS_DESCRIPTION, toGroupDn("nobody"));
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<RoleType> roleFools = findObjectByName(RoleType.class, GROUP_FOOLS_CN);
    assertNull("Unexpected role " + roleFools, roleFools);
    assertStepSyncToken(getSyncTaskOid(), 8, 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 49 with RoleType

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

the class ModifyAssignmentTest method test30DeleteAssignment.

@Test
public void test30DeleteAssignment() throws Exception {
    //given
    //when
    //        ObjectModificationType modification = prismContext.getPrismJaxbProcessor().unmarshalObject(
    //                new File(TEST_DIR, "modify-delete-assignment.xml"), ObjectModificationType.class);
    //
    //        ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, RoleType.class, prismContext);
    AssignmentType a = new AssignmentType();
    a.setId(4L);
    ObjectDelta<RoleType> delta = ObjectDelta.createModificationDeleteContainer(RoleType.class, "00000000-8888-6666-0000-100000000005", RoleType.F_ASSIGNMENT, prismContext, a);
    OperationResult result = new OperationResult("delete assignment");
    repositoryService.modifyObject(RoleType.class, delta.getOid(), delta.getModifications(), result);
    result.recomputeStatus();
    result.recordSuccessIfUnknown();
    //then
    AssertJUnit.assertTrue(result.isSuccess());
    result = new OperationResult("get role");
    PrismObject repoRole = repositoryService.getObject(RoleType.class, ROLE_OID, null, result);
    result.recomputeStatus();
    result.recordSuccessIfUnknown();
    AssertJUnit.assertTrue(result.isSuccess());
    PrismContainer inducement = repoRole.findContainer(new ItemPath(RoleType.F_INDUCEMENT));
    AssertJUnit.assertNotNull(inducement);
    AssertJUnit.assertEquals(3, inducement.getValues().size());
    PrismContainer assignment = repoRole.findContainer(new ItemPath(AbstractRoleType.F_ASSIGNMENT));
    AssertJUnit.assertNotNull(assignment);
    AssertJUnit.assertEquals(1, assignment.getValues().size());
    AssertJUnit.assertNotNull(assignment.getValue(1L));
    Session session = open();
    try {
        Query query = session.createSQLQuery("select count(*) from m_assignment where owner_oid=:oid and id=:id");
        query.setParameter("oid", delta.getOid());
        query.setParameter("id", 4);
        Number number = (Number) query.uniqueResult();
        AssertJUnit.assertEquals(0, number.intValue());
    } finally {
        close(session);
    }
}
Also used : Query(org.hibernate.Query) 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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 50 with RoleType

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

the class AbstractTestForExchangeConnector method listRequestableRoles.

protected Collection<RoleType> listRequestableRoles() throws SAXException, IOException, FaultMessage, JAXBException {
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:requestable</path>" + "<value>true</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

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