Ejemplo n.º 1
0
        public void GetDiscussionThreadPostTest()
        {
            DiscussionPostTest post = new DiscussionPostTest();

            post.SetUp();
            int post_id = post.Create(GetAdminTicket());

            WebDiscussionService.TransitDiscussionPost t_post = EndPoint.GetDiscussionPostById(GetAdminTicket(), post_id);
            Console.WriteLine("Thread Id: {0}", t_post.DiscussionThreadId);
            WebDiscussionService.TransitDiscussionPost t_threadpost = EndPoint.GetDiscussionThreadPost(GetAdminTicket(), t_post.DiscussionThreadId);
            Assert.AreEqual(t_post.Id, t_threadpost.Id);
            post.Delete(GetAdminTicket(), post_id);
            post.TearDown();
        }
        protected void GetOrCreateDiscussionIdTest <TransitType, WebServiceType>(
            string typename,
            WebServiceTest <TransitType, WebServiceType> objecttest)
            where WebServiceType : new()
        {
            // create a discussion

            Console.WriteLine("Type: {0}", typename);

            objecttest.SetUp();
            int objecttest_id = objecttest.Create(GetAdminTicket());

            Assert.IsTrue(objecttest_id > 0);

            int discussion_id = EndPoint.GetOrCreateDiscussionId(_user.ticket, typename, objecttest_id);

            Assert.IsTrue(discussion_id > 0);

            WebDiscussionService.TransitDiscussion t_discussion = EndPoint.GetDiscussionById(
                _user.ticket, discussion_id);

            Console.WriteLine("Discussion: {0}", t_discussion.Name);

            string redirecturi = EndPoint.GetDiscussionRedirectUri(_user.ticket, discussion_id);

            Console.WriteLine("Uri: {0}", redirecturi);

            Assert.AreEqual(t_discussion.ParentObjectUri, redirecturi);
            Assert.AreEqual(t_discussion.ParentObjectType, typename);

            Console.WriteLine("Parent name: {0}", t_discussion.ParentObjectName);

            // post to a discussion as a regular user
            WebDiscussionService.TransitDiscussionPost t_post = new WebDiscussionService.TransitDiscussionPost();
            t_post.DiscussionId = discussion_id;
            t_post.AccountId    = _user.id;
            t_post.Body         = GetNewString();
            t_post.Subject      = GetNewString();
            t_post.Id           = EndPoint.CreateOrUpdateDiscussionPost(_user.ticket, t_post);

            objecttest.Delete(GetAdminTicket(), objecttest_id);
            objecttest.TearDown();

            t_discussion = EndPoint.GetDiscussionById(_user.ticket, discussion_id);
            Assert.IsNull(t_discussion, "Discussion has not been deleted with object.");
        }
Ejemplo n.º 3
0
        public void DeleteAccountWithoutContentTests()
        {
            UserInfo           user = CreateUserWithVerifiedEmailAddress();
            DiscussionPostTest post = new DiscussionPostTest();

            post.SetUp();
            WebDiscussionService.TransitDiscussionPost t_post = post.GetTransitInstance();
            t_post.AccountId = user.id;
            t_post.Id        = post.EndPoint.CreateOrUpdateDiscussionPost(user.ticket, t_post);
            Console.WriteLine("Post: {0}", t_post.Id);
            int count1 = post.EndPoint.GetDiscussionPostsCount(GetAdminTicket(), t_post.DiscussionId);

            EndPoint.DeleteAccount(GetAdminTicket(), user.id);
            // deleting a user with default options doesn't delete all his posts
            int count2 = post.EndPoint.GetDiscussionPostsCount(GetAdminTicket(), t_post.DiscussionId);

            Assert.AreEqual(count1, count2);
            post.TearDown();
        }
Ejemplo n.º 4
0
        public void MoveDiscussionThreadTest()
        {
            DiscussionTest discussion    = new DiscussionTest();
            int            discussion_id = discussion.Create(GetAdminTicket());

            discussion.SetUp();
            DiscussionPostTest post = new DiscussionPostTest();

            post.SetUp();
            int post_id = post.Create(GetAdminTicket());

            WebDiscussionService.TransitDiscussionPost t_post = EndPoint.GetDiscussionPostById(GetAdminTicket(), post_id);
            Console.WriteLine("Thread Id: {0}", t_post.DiscussionThreadId);
            EndPoint.MoveDiscussionThread(GetAdminTicket(), t_post.DiscussionThreadId, discussion_id);
            WebDiscussionService.TransitDiscussionThread t_thread = EndPoint.GetDiscussionThreadById(GetAdminTicket(), t_post.DiscussionThreadId);
            Assert.AreEqual(t_thread.DiscussionId, discussion_id);
            post.Delete(GetAdminTicket(), post_id);
            post.TearDown();
            discussion.Delete(GetAdminTicket(), discussion_id);
            discussion.TearDown();
        }
Ejemplo n.º 5
0
        public void DeleteAccountWithContentTests()
        {
            UserInfo user = CreateUserWithVerifiedEmailAddress();
            // create a post
            DiscussionPostTest post = new DiscussionPostTest();

            post.SetUp();
            WebDiscussionService.TransitDiscussionPost t_post = post.GetTransitInstance();
            t_post.AccountId = user.id;
            t_post.Id        = post.EndPoint.CreateOrUpdateDiscussionPost(user.ticket, t_post);
            Console.WriteLine("Post: {0}", t_post.Id);
            int count1 = post.EndPoint.GetDiscussionPostsCount(GetAdminTicket(), t_post.DiscussionId);

            WebAccountService.TransitAccountDeleteOptions options = new WebAccountService.TransitAccountDeleteOptions();
            options.DeleteContent = true;
            EndPoint.DeleteAccountWithOptions(GetAdminTicket(), user.id, options);
            // deleting a user with content
            int count2 = post.EndPoint.GetDiscussionPostsCount(GetAdminTicket(), t_post.DiscussionId);

            Assert.AreEqual(count1 - 1, count2);
            post.TearDown();
        }
Ejemplo n.º 6
0
        public void EnableDisableCommentsTest()
        {
            WebBlogService.TransitAccountBlogPost t_post = GetTransitInstance();
            int post_id = Create(GetAdminTicket(), t_post);

            Console.WriteLine("Post: {0}", post_id);
            // post a comment
            WebDiscussionService.WebDiscussionService DiscussionEndpoint = new SnCore.Web.Soap.Tests.WebDiscussionService.WebDiscussionService();
            int discussion_id = DiscussionEndpoint.GetOrCreateDiscussionId(GetAdminTicket(), "AccountBlogPost", post_id);

            Console.WriteLine("Discussion: {0}", discussion_id);
            WebDiscussionService.TransitDiscussionPost t_discussion_post_1 = new WebDiscussionService.TransitDiscussionPost();
            t_discussion_post_1.Body         = GetNewString();
            t_discussion_post_1.DiscussionId = discussion_id;
            t_discussion_post_1.Subject      = GetNewString();
            t_discussion_post_1.Id           = DiscussionEndpoint.CreateOrUpdateDiscussionPost(_user.ticket, t_discussion_post_1);
            Console.WriteLine("Post: {0}", t_discussion_post_1.Id);
            // disable comments on the blog
            WebBlogService.TransitAccountBlog t_blog = EndPoint.GetAccountBlogById(GetAdminTicket(), _blog_id);
            t_blog.EnableComments = false;
            EndPoint.CreateOrUpdateAccountBlog(GetAdminTicket(), t_blog);
            // try to post again
            try
            {
                WebDiscussionService.TransitDiscussionPost t_discussion_post_2 = new WebDiscussionService.TransitDiscussionPost();
                t_discussion_post_2.Body         = GetNewString();
                t_discussion_post_2.DiscussionId = discussion_id;
                t_discussion_post_2.Subject      = GetNewString();
                t_discussion_post_2.Id           = DiscussionEndpoint.CreateOrUpdateDiscussionPost(_user.ticket, t_discussion_post_2);
                Console.WriteLine("Post: {0}", t_discussion_post_2.Id);
                Assert.IsTrue(false, "Expected an access denied.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Expected exception: {0}", ex.Message);
                Assert.IsTrue(ex.Message.StartsWith("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied"));
            }
            Delete(GetAdminTicket(), post_id);
        }
Ejemplo n.º 7
0
        public void GetAccountGroupDiscussionTest()
        {
            // make sure that anyone can access a discussion of a public group
            // create a public group
            WebGroupService.TransitAccountGroup t_group = GetTransitInstance();
            t_group.IsPrivate = false;
            t_group.Id        = Create(GetAdminTicket(), t_group);
            // fetch the discussion
            WebDiscussionService.WebDiscussionService discussionendpoint = new WebDiscussionService.WebDiscussionService();
            int discussion_id = discussionendpoint.GetOrCreateDiscussionId(GetAdminTicket(), "AccountGroup", t_group.Id);

            Console.WriteLine("Discussion: {0}", discussion_id);
            Assert.AreNotEqual(0, discussion_id);
            // make sure a regular user can't post a thread (must be member of a group)
            try
            {
                WebDiscussionService.TransitDiscussionPost t_post1 = new WebDiscussionService.TransitDiscussionPost();
                t_post1.AccountId          = _user.id;
                t_post1.DiscussionId       = discussion_id;
                t_post1.DiscussionThreadId = 0;
                t_post1.Subject            = GetNewString();
                t_post1.Body = GetNewString();
                t_post1.Id   = discussionendpoint.CreateOrUpdateDiscussionPost(_user.ticket, t_post1);
                Console.WriteLine("Post: {0}", t_post1.Id);
                Assert.IsFalse(true, "Expected an Access Denied exception.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
                Assert.AreEqual("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied",
                                ex.Message.Split("\n".ToCharArray(), 2)[0],
                                string.Format("Unexpected exception: {0}", ex.Message));
            }
            // post a new thread (as admin)
            WebDiscussionService.TransitDiscussionPost t_post2 = new WebDiscussionService.TransitDiscussionPost();
            t_post2.AccountId          = GetAdminAccount().Id;
            t_post2.DiscussionId       = discussion_id;
            t_post2.DiscussionThreadId = 0;
            t_post2.Subject            = GetNewString();
            t_post2.Body = GetNewString();
            t_post2.Id   = discussionendpoint.CreateOrUpdateDiscussionPost(GetAdminTicket(), t_post2);
            Console.WriteLine("Post: {0}", t_post2.Id);
            // make sure regular users can't read posts from a public discussion
            try
            {
                WebDiscussionService.TransitDiscussionPost t_post3 = discussionendpoint.GetDiscussionPostById(
                    _user.ticket, t_post2.Id);
                Console.WriteLine("Post: {0}", t_post3.Id);
                Assert.IsFalse(true, "Expected an Access Denied exception.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
                Assert.AreEqual("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied",
                                ex.Message.Split("\n".ToCharArray(), 2)[0],
                                string.Format("Unexpected exception: {0}", ex.Message));
            }
            // join the user to the group
            WebGroupService.TransitAccountGroupAccount t_account = new WebGroupService.TransitAccountGroupAccount();
            t_account.AccountGroupId  = t_group.Id;
            t_account.AccountId       = _user.id;
            t_account.IsAdministrator = false;
            t_account.Id = EndPoint.CreateOrUpdateAccountGroupAccount(GetAdminTicket(), t_account);
            Console.WriteLine("Joined: {0}", t_account.Id);
            Assert.AreNotEqual(0, t_account.Id);
            // the user now can retrieve the post
            WebDiscussionService.TransitDiscussionPost t_post4 = discussionendpoint.GetDiscussionPostById(
                _user.ticket, t_post2.Id);
            Console.WriteLine("Post: {0}", t_post4.Id);
            // done
            Delete(GetAdminTicket(), t_group.Id);
        }