public void Can_Get_Recursive_Permissions_When_Node_Has_No_Permissions()
        {
            Scaffold.ContentType(_contentTypeService);
            IContentType contentType = _contentTypeService.GetContentType("textpage");

            IContent root  = Scaffold.Node(_contentService);
            IContent child = Scaffold.Node(_contentService, root.Id);

            List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(root.ToPublishedContent());

            Assert.Null(permissions);

            permissions = _configService.GetRecursivePermissionsForNode(child.ToPublishedContent());
            Assert.Null(permissions);

            // add a permission so something is returned...
            var poco = new UserGroupPermissionsPoco
            {
                ContentTypeId = contentType.Id,
                GroupId       = 3,
                Permission    = 0
            };

            _configService.UpdateContentTypeConfig(new Dictionary <int, List <UserGroupPermissionsPoco> >
            {
                { 0, new List <UserGroupPermissionsPoco> {
                      poco
                  } }
            });

            permissions = _configService.GetRecursivePermissionsForNode(child.ToPublishedContent());
            Assert.NotNull(permissions);
        }
Exemple #2
0
        public void Can_Convert_To_IPublishedContent()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            IPublishedContent content = node.ToPublishedContent();

            Assert.NotNull(content);
        }
Exemple #3
0
        public void Can_Get_Content_Type()
        {
            Scaffold.ContentType(_contentTypeService);
            IEnumerable <IContentType> contentTypes = _contentTypeService.GetAllContentTypes();
            IContentType textpage = contentTypes.First(x => x.Alias == "textpage");

            IContentType result = _utility.GetContentType(textpage.Id);

            Assert.Equal(textpage.Id, result.Id);
        }
Exemple #4
0
        public void Can_Get_Node_Name()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent home = Scaffold.Node(_contentService);

            string name = _utility.GetNodeName(home.Id);

            Assert.NotNull(name);
            Assert.Equal(home.Name, name);
        }
Exemple #5
0
        public void Can_Generate_Preview()
        {
            Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService);
            IContent node = Scaffold.Node(ApplicationContext.Current.Services.ContentService);
            Guid     guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 0, node.Id));

            _previewService.Generate(node.Id, 0, guid);
        }
Exemple #6
0
        public void Can_Get_Node()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent home = Scaffold.Node(_contentService);

            object node = _utility.GetContent(home.Id);

            Assert.NotNull(node);
            Assert.Equal(home.Id, node.Get("Id"));
            Assert.IsAssignableFrom <IContent>(node);
        }
        public InstancesServiceTests()
        {
            Host.Run(new[] { "install y" }).Wait();

            Scaffold.Run();
            Scaffold.Config();
            Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService);

            _service      = new InstancesService();
            _tasksService = new TasksService();
        }
Exemple #8
0
        public async void Get_Pending_Tasks_Response_Is_Generic_When_No_Settings_Or_Flow()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            // generic response if no settings
            object content = await _tasksController.GetNodePendingTasks(node.Id).GetContent();

            Assert.Null(content.Get("settings"));
            Assert.Null(content.Get("noFlow"));
        }
Exemple #9
0
        public void Can_Get_Content_Type_Permission_For_Node()
        {
            Scaffold.ContentType(_contentTypeService);
            IContentType type = _contentTypeService.GetContentType("textpage");
            IContent     node = Scaffold.Node(_contentService);

            Dictionary <int, List <UserGroupPermissionsPoco> > perms = Scaffold.Permissions(0, 2, 0, type.Id);

            _configService.UpdateContentTypeConfig(perms);

            Assert.NotNull(_configService.GetPermissionsForNode(node.Id));
        }
        public ConfigServiceTests()
        {
            Host.Run(new[] { "install y" }).Wait();

            _configService = new ConfigService(new PocoRepository());

            _contentService     = ApplicationContext.Current.Services.ContentService;
            _contentTypeService = ApplicationContext.Current.Services.ContentTypeService;

            Scaffold.Run();
            Scaffold.Config();
            Scaffold.ContentType(_contentTypeService);
        }
        public async void Can_Get_ContentTypes()
        {
            JArray result = await _settingsController.GetContentTypes().GetContent();

            Assert.NotNull(result);

            Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService, "TestType");
            Scaffold.ContentType(ApplicationContext.Current.Services.ContentTypeService, "AnotherType");

            result = await _settingsController.GetContentTypes().GetContent();

            Assert.Equal(2, result.Count);
            Assert.Equal("TestType", result[0]["name"]);
        }
Exemple #12
0
        public async void Can_Get_Paged_Node_Tasks()
        {
            // get an error if the node doesn't exist
            //object response = await _tasksController.GetNodeTasks(666, -1, -1).GetContent();
            //Assert.Equal("NullReferenceException", (string)response.Get("ExceptionType"));
            //Assert.Equal(MagicStrings.ErrorGettingPendingTasksForNode.Replace("{id}", "666"), (string)response.Get("ExceptionMessage"));

            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id));
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));

            // needs flow or function exits
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 2);

            _configService.UpdateNodeConfig(config);

            JObject content = await _tasksController.GetNodeTasks(node.Id, 10, 1).GetContent();

            Assert.Equal(1, content.Value <int>("totalPages"));
            Assert.Equal(10, content.Value <int>("count"));
            Assert.Equal(3, content.Value <JArray>("items").Count);

            // when 3 tasks, 1 per page, page 2 should be 1 item
            content = await _tasksController.GetNodeTasks(node.Id, 1, 2).GetContent();

            Assert.Equal(3, content.Value <int>("totalPages"));
            Assert.Equal(1, content.Value <int>("count"));
            Assert.Single(content.Value <JArray>("items"));

            // when 5 tasks, and 2 per page, page 2 should be 2 items
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));

            content = await _tasksController.GetNodeTasks(node.Id, 2, 2).GetContent();

            Assert.Equal(3, content.Value <int>("totalPages"));
            Assert.Equal(2, content.Value <int>("count"));
            Assert.Equal(2, content.Value <JArray>("items").Count);
        }
Exemple #13
0
        public void Can_Get_Recursive_Permissions_For_Node()
        {
            Scaffold.Config();
            Scaffold.ContentType(_contentTypeService);
            var type = _contentTypeService.GetContentType("textpage");

            var mock = new MockRepository(MockBehavior.Default);
            Mock <IPublishedContent> content = mock.Create <IPublishedContent>();

            content.Setup(x => x.Id).Returns(1089);

            List <UserGroupPermissionsPoco> permissions = _configService.GetRecursivePermissionsForNode(content.Object);

            // node has permissions, returns without recursion
            Assert.NotNull(permissions);

            // todo - to recurse, we need a contenttype
        }
Exemple #14
0
        public void Can_Get_Ancestor_Permissions()
        {
            // scaffold
            Scaffold.ContentType(_contentTypeService);
            IContent root       = Scaffold.Node(_contentService);
            IContent child      = Scaffold.Node(_contentService, root.Id);
            IContent childChild = Scaffold.Node(_contentService, child.Id);

            // set permissions on root
            // mock some data
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(root.Id, 3, 2);

            _configService.UpdateNodeConfig(config);

            bool hasFlow = _utility.HasFlow(childChild.Id);

            Assert.True(hasFlow);
        }
        public async void Can_Get_Node_Pending_Tasks()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id));
            _tasksService.InsertTask(Scaffold.Task(guid));

            // needs flow or function exits
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 0);

            _configService.UpdateNodeConfig(config);

            JObject content = await _tasksController.GetNodePendingTasks(node.Id).GetContent();

            Assert.Single(content.Value <JArray>("items"));
        }