コード例 #1
0
        public virtual void testProcessTaskAddGroupIdentityLinkWithUpdatePersmissionOnTask()
        {
            // given
            startProcessInstanceByKey(PROCESS_KEY);
            string taskId = selectSingleTask().Id;

            authRule.createGrantAuthorization(TASK, taskId, userId, UPDATE);

            // when
            taskService.addGroupIdentityLink(taskId, ACCOUNTING_GROUP, IdentityLinkType.CANDIDATE);

            // then
            authRule.disableAuthorization();
            IList <IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);

            authRule.disableAuthorization();

            assertNotNull(linksForTask);
            assertEquals(1, linksForTask.Count);

            IdentityLink identityLink = linksForTask[0];

            assertNotNull(identityLink);

            assertEquals(ACCOUNTING_GROUP, identityLink.GroupId);
            assertEquals(IdentityLinkType.CANDIDATE, identityLink.Type);
            verifyGroupAuthorization(ACCOUNTING_GROUP);
        }
コード例 #2
0
        // TaskService#addUserIdentityLink() ///////////////////////////////////

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testStandaloneTaskAddUserIdentityLinkAndUserOwnerPermissions()
        public virtual void testStandaloneTaskAddUserIdentityLinkAndUserOwnerPermissions()
        {
            // given
            string taskId = "myTask";

            createTask(taskId);

            authRule.createGrantAuthorization(TASK, taskId, userId, UPDATE);

            // when
            taskService.addUserIdentityLink(taskId, DEMO, IdentityLinkType.CANDIDATE);

            // then
            authRule.disableAuthorization();
            IList <IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);

            authRule.disableAuthorization();

            assertNotNull(linksForTask);
            assertEquals(1, linksForTask.Count);

            IdentityLink identityLink = linksForTask[0];

            assertNotNull(identityLink);

            assertEquals(DEMO, identityLink.UserId);
            assertEquals(IdentityLinkType.CANDIDATE, identityLink.Type);
            verifyUserAuthorization(DEMO);

            taskService.deleteTask(taskId, true);
        }
コード例 #3
0
        // TaskService#addGroupIdentityLink() ///////////////////////////////////

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testStandaloneTaskAddGroupIdentityLink()
        public virtual void testStandaloneTaskAddGroupIdentityLink()
        {
            // given
            string taskId = "myTask";

            createTask(taskId);

            authRule.createGrantAuthorization(TASK, taskId, userId, UPDATE);

            // when
            taskService.addGroupIdentityLink(taskId, ACCOUNTING_GROUP, IdentityLinkType.CANDIDATE);

            // then
            authRule.disableAuthorization();
            IList <IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);

            authRule.disableAuthorization();

            assertNotNull(linksForTask);
            assertEquals(1, linksForTask.Count);

            IdentityLink identityLink = linksForTask[0];

            assertNotNull(identityLink);

            assertEquals(ACCOUNTING_GROUP, identityLink.GroupId);
            assertEquals(IdentityLinkType.CANDIDATE, identityLink.Type);

            verifyGroupAuthorization(ACCOUNTING_GROUP);

            taskService.deleteTask(taskId, true);
        }
コード例 #4
0
        public virtual void testCandidateGroupLink()
        {
            try
            {
                identityService.AuthenticatedUserId = "demo";

                runtimeService.startProcessInstanceByKey("IdentityLinksProcess");

                string taskId = taskService.createTaskQuery().singleResult().Id;

                taskService.addCandidateGroup(taskId, "muppets");

                IList <IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
                IdentityLink         identityLink  = identityLinks[0];

                assertEquals("muppets", identityLink.GroupId);
                assertNull("kermit", identityLink.UserId);
                assertEquals(IdentityLinkType.CANDIDATE, identityLink.Type);
                assertEquals(taskId, identityLink.TaskId);

                assertEquals(1, identityLinks.Count);

                if (processEngineConfiguration.HistoryLevel.Id >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL)
                {
                    IList <Event> taskEvents = taskService.getTaskEvents(taskId);
                    assertEquals(1, taskEvents.Count);
                    Event taskEvent = taskEvents[0];
                    assertEquals(org.camunda.bpm.engine.task.Event_Fields.ACTION_ADD_GROUP_LINK, taskEvent.Action);
                    IList <string> taskEventMessageParts = taskEvent.MessageParts;
                    assertEquals("muppets", taskEventMessageParts[0]);
                    assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts[1]);
                    assertEquals(2, taskEventMessageParts.Count);
                }

                taskService.deleteCandidateGroup(taskId, "muppets");

                if (processEngineConfiguration.HistoryLevel.Id >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL)
                {
                    IList <Event> taskEvents = taskService.getTaskEvents(taskId);
                    Event         taskEvent  = findTaskEvent(taskEvents, org.camunda.bpm.engine.task.Event_Fields.ACTION_DELETE_GROUP_LINK);
                    assertEquals(org.camunda.bpm.engine.task.Event_Fields.ACTION_DELETE_GROUP_LINK, taskEvent.Action);
                    IList <string> taskEventMessageParts = taskEvent.MessageParts;
                    assertEquals("muppets", taskEventMessageParts[0]);
                    assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts[1]);
                    assertEquals(2, taskEventMessageParts.Count);
                    assertEquals(2, taskEvents.Count);
                }

                assertEquals(0, taskService.getIdentityLinksForTask(taskId).Count);
            }
            finally
            {
                identityService.clearAuthentication();
            }
        }
コード例 #5
0
        public OpBuddy AddBuddy(string link)
        {
            IdentityLink ident = IdentityLink.Decode(link);

            if (!Utilities.MemCompare(ident.PublicOpID, Core.User.Settings.PublicOpID))
            {
                throw new Exception("This buddy link is not for " + Core.User.Settings.Operation);
            }

            return(AddBuddy(ident.Name, ident.PublicKey));
        }
コード例 #6
0
        public void TestIdentityLink1()
        {
            IdentityLink data = new IdentityLink();

            data.Group             = "group";
            data.IdentityLinkId    = Guid.NewGuid().ToString();
            data.ProcessInstanceId = Guid.NewGuid().ToString();
            data.ProcessTaskId     = Guid.NewGuid().ToString();
            data.Type     = EIdentityLinkType.Owner;
            data.Username = "******";
            Assert.IsNotNull(data.Group);
            Assert.IsNotNull(data.IdentityLinkId);
            Assert.IsNotNull(data.ProcessInstanceId);
            Assert.IsNotNull(data.ProcessTaskId);
            Assert.IsNotNull(data.Type);
            Assert.IsNotNull(data.Username);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPropagateTenantIdToCandidateStarterUser()
        public virtual void shouldPropagateTenantIdToCandidateStarterUser()
        {
            // when
            DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_USER).tenantId(TENANT_ONE);

            testRule.deploy(builder);

            // then
            ProcessDefinition    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
            IList <IdentityLink> links             = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.Id);

            assertEquals(1, links.Count);

            IdentityLink link = links[0];

            assertNotNull(link.TenantId);
            assertEquals(TENANT_ONE, link.TenantId);
        }
コード例 #8
0
        private bool PreProcessLink(string arg)
        {
            try
            {
                arg = arg.TrimEnd('/'); // copy so modifications arent permanent

                if (arg.Contains("/file/"))
                {
                    FileLink link = FileLink.Decode(arg, null);

                    var ui = FindCoreUI(link.PublicOpID);

                    if (ui != null)
                    {
                        ShareService share = ui.Core.GetService(DeOps.Services.ServiceIDs.Share) as ShareService;
                        share.DownloadLink(arg);

                        if (ui.GuiMain != null && !ui.GuiMain.ShowExistingView(typeof(SharingView)))
                        {
                            ui.ShowView(new SharingView(ui.Core, ui.Core.UserID), true);
                        }

                        return(true);
                    }
                }

                else if (arg.Contains("/ident/"))
                {
                    IdentityLink link = IdentityLink.Decode(arg);

                    var target = FindCoreUI(link.PublicOpID);

                    if (target != null)
                    {
                        BuddyView.AddBuddyDialog(target.Core, arg);
                        return(true);
                    }
                }
            }
            catch { }

            return(false);
        }
コード例 #9
0
        public virtual void testOwnerLink()
        {
            Task task = taskService.newTask("task");

            task.Owner = "owner";
            taskService.saveTask(task);

            IList <IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.Id);

            assertNotNull(identityLinks);
            assertEquals(1, identityLinks.Count);

            IdentityLink identityLink = identityLinks[0];

            assertEquals(IdentityLinkType.OWNER, identityLink.Type);
            assertEquals("owner", identityLink.UserId);
            assertEquals("task", identityLink.TaskId);

            taskService.deleteTask(task.Id, true);
        }
コード例 #10
0
        public virtual void testAssigneeLink()
        {
            Task task = taskService.newTask("task");

            task.Assignee = "assignee";
            taskService.saveTask(task);

            IList <IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.Id);

            assertNotNull(identityLinks);
            assertEquals(1, identityLinks.Count);

            IdentityLink identityLink = identityLinks[0];

            assertEquals(IdentityLinkType.ASSIGNEE, identityLink.Type);
            assertEquals("assignee", identityLink.UserId);
            assertEquals("task", identityLink.TaskId);

            taskService.deleteTask(task.Id, true);
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIdentityLinkCaching()
        public virtual void testIdentityLinkCaching()
        {
            string[] taskIds = new string[] { "test" };
            // mock identityLinks and query
            IdentityLink link1 = mock(typeof(IdentityLink));

            when(link1.TaskId).thenReturn(taskIds[0]);
            IdentityLink link2 = mock(typeof(IdentityLink));

            when(link2.TaskId).thenReturn(taskIds[0]);
            when(processEngine.TaskService.getIdentityLinksForTask(anyString())).thenReturn(Arrays.asList(link1, link2));

            // configure cache
            HalRelationCacheConfiguration configuration = new HalRelationCacheConfiguration();

            configuration.CacheImplementationClass = typeof(DefaultHalResourceCache);
            IDictionary <string, object> halIdentityLinkConfig = new Dictionary <string, object>();

            halIdentityLinkConfig["capacity"]      = 100;
            halIdentityLinkConfig["secondsToLive"] = 10000;
            configuration.addCacheConfiguration(typeof(HalIdentityLink), halIdentityLinkConfig);

            contextListener.configureCaches(configuration);

            // cache exists and is empty
            DefaultHalResourceCache cache = (DefaultHalResourceCache)Hal.Instance.getHalRelationCache(typeof(HalIdentityLink));

            assertNotNull(cache);
            assertEquals(0, cache.size());

            // get link resolver and resolve identity link
            HalLinkResolver linkResolver = Hal.Instance.getLinkResolver(typeof(IdentityRestService));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.rest.hal.HalResource<?>> halIdentityLinks = linkResolver.resolveLinks(taskIds, processEngine);
            IList <HalResource <object> > halIdentityLinks = linkResolver.resolveLinks(taskIds, processEngine);

            assertEquals(2, halIdentityLinks.Count);
            assertEquals(1, cache.size());

            assertEquals(halIdentityLinks, cache.get(taskIds[0]));
        }
コード例 #12
0
        public virtual void testCandidateUserLink()
        {
            runtimeService.startProcessInstanceByKey("IdentityLinksProcess");

            string taskId = taskService.createTaskQuery().singleResult().Id;

            taskService.addCandidateUser(taskId, "kermit");

            IList <IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
            IdentityLink         identityLink  = identityLinks[0];

            assertNull(identityLink.GroupId);
            assertEquals("kermit", identityLink.UserId);
            assertEquals(IdentityLinkType.CANDIDATE, identityLink.Type);
            assertEquals(taskId, identityLink.TaskId);

            assertEquals(1, identityLinks.Count);

            taskService.deleteCandidateUser(taskId, "kermit");

            assertEquals(0, taskService.getIdentityLinksForTask(taskId).Count);
        }
コード例 #13
0
        public virtual void testCustomLinkGroupLink()
        {
            runtimeService.startProcessInstanceByKey("IdentityLinksProcess");

            string taskId = taskService.createTaskQuery().singleResult().Id;

            taskService.addGroupIdentityLink(taskId, "muppets", "playing");

            IList <IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
            IdentityLink         identityLink  = identityLinks[0];

            assertEquals("muppets", identityLink.GroupId);
            assertNull("kermit", identityLink.UserId);
            assertEquals("playing", identityLink.Type);
            assertEquals(taskId, identityLink.TaskId);

            assertEquals(1, identityLinks.Count);

            taskService.deleteGroupIdentityLink(taskId, "muppets", "playing");

            assertEquals(0, taskService.getIdentityLinksForTask(taskId).Count);
        }
コード例 #14
0
        [Fact] public async Task Execute()
        {
            //var user = await this.identityManager.FindUserByNameAsync("felix");
            //var group = await this.identityManager.FindGroupByNameAsync("tests");

            var identityLinks = new IdentityLink[]
            {
                new IdentityLink()
                {
                    UserId = "test", Type = "starter"
                },
                new IdentityLink()
                {
                    GroupId = "tests", Type = "tests"
                }
            };

            var procDefId = 1;

            //add
            await this.deploymentManager.AddIdentityLinksAsync(procDefId, identityLinks);

            var items = await this.deploymentManager.GetIdentityLinksAsync(procDefId);

            Assert.True(items.Count >= identityLinks.Length);

            //Remove
            var array = items.Select(x => x.Id).ToArray();

            await this.deploymentManager.RemoveIdentityLinksAsync(array);

            items = await this.deploymentManager.GetIdentityLinksAsync(procDefId);

            Assert.True(items.Count == 0);

            this.Commit();
        }