Exemple #1
0
        public void GetCallingUserInfo_AsBannedUser_ReturnsBannedStatus()
        {
            Console.WriteLine("Before GetCallingUserInfo_AsBannedUser_ReturnsBannedStatus");

            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserBanned();
            request.RequestPageWithFullURL(callinguserfull_secure_url);

            BBC.Dna.Users.User user = (BBC.Dna.Users.User)StringUtils.DeserializeObject(request.GetLastResponseAsXML().OuterXml, typeof(BBC.Dna.Users.User));

            Assert.AreEqual("Banned", user.StatusAsString);

            Console.WriteLine("After GetCallingUserInfo_AsBannedUser_ReturnsBannedStatus");
        }
Exemple #2
0
        public void bannedUser()
        {
            Console.WriteLine("Before userTypes - bannedUser");

            DnaTestURLRequest request = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);
            request.SetCurrentUserBanned();

            doIt_xml(request, HttpStatusCode.Unauthorized);

            Console.WriteLine("After userTypes - bannedUser");
        }
        public void CreateThreadedRating_WithBannedUser()
        {
            Console.WriteLine("Before CreateThreadedRating_WithBannedUser");

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserBanned();
            //create the forum
            RatingForum ratingForum = RatingForumCreate("tests", Guid.NewGuid().ToString());

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string ratingForumXml = String.Format("<rating xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text><rating>{1}</rating>" +
                "</rating>", text, 5);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, ratingForum.Id);
            // now get the response
            try
            {
                request.RequestPageWithFullURL(url, ratingForumXml, "text/xml");
            }
            catch { }
            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized);


            Console.WriteLine("After CreateThreadedRating_WithBannedUser");
        }
Exemple #4
0
        public void Test06DefaultDetailsReturnUserBanned()
        {
            Console.WriteLine("Before UserDetailsTests - Test06DefaultDetailsReturnUserBanned");

            //request the page
            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserBanned();
            request.RequestPage("UserDetails?skin=purexml");

            // now get the response
            XmlDocument xml = request.GetLastResponseAsXML();

            //validate response
            ValidateBaseXML(xml);

            XmlNode xmlMessage = xml.SelectSingleNode("/H2G2/USER-DETAILS-FORM/MESSAGE");
            Assert.IsTrue(xmlMessage != null, "Incorrect return message");
            Assert.IsTrue(xmlMessage.InnerText != String.Empty, "Incorrect return message");
            Assert.IsTrue(xmlMessage.Attributes["TYPE"].Value == "restricteduser", "Incorrect return message");
            

            Console.WriteLine("After UserDetailsTests - Test06DefaultDetailsReturnUserBanned");
        }
        public void CreateCommentHtml_WithBannedUser()
        {
            Console.WriteLine("Before CreateComment");

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserBanned();
            //create the forum
            CommentForum commentForum = GetCommentsTests().CommentForumCreate("tests", Guid.NewGuid().ToString());

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string commentForumXml = String.Format("text={0}", text);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/create.htm?format=XML", _sitename, commentForum.Id);
            request.RequestPageWithFullURL(url, commentForumXml, "application/x-www-form-urlencoded", null, headers);
            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.MovedPermanently, "Not Moved - Status Code = " + request.CurrentWebResponse.StatusCode.ToString());
            Assert.IsTrue(request.CurrentWebResponse.Headers["Location"] == headers["referer"] + "?resultCode=" + ErrorType.UserIsBanned.ToString());
        }
        public void ReadAs_BannedUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);

            string forumId = testUtils_ratingsAPI.makeTestForum();
            string ratingId = testUtils_ratingsAPI.makeTestItem(forumId);

            string url = makeReadPickUrl(forumId);

            markComment(ratingId);

            myRequest.SetCurrentUserBanned();

            try
            {
                myRequest.RequestPageWithFullURL(url);
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.OK,
                "Failed listing editor's picks. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaRatingForum);
            myValidator.Validate();
        }
        public void CreateAs_BannedUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);

            string forumId = testUtils_ratingsAPI.makeTestForum();
            string ratingId = testUtils_ratingsAPI.makeTestItem(forumId);

            string url = makeCreatePickUrl(ratingId);
            string postData = testUtils_ratingsAPI.makeTimeStamp(); // needs some sort of post data otherwise it uses GET

            myRequest.SetCurrentUserBanned();

            try
            {
                myRequest.RequestPageWithFullURL(url, postData, "text/xml");
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized,
                "Should have been unauthorised. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaError);
            myValidator.Validate();
        }
Exemple #8
0
        public void CreateForumPost_WithBannedUser_ThrowsException()
        {
            Console.WriteLine("Before CreateForumPost_WithBannedUser_ThrowsException");

            // TODO: this is currently failing, fix this when we have the new user code

            string forum = "7619338";
            string thread = "31";
            string inReplyTo = "1";
            string subject = "test";
            string text = "test";
            string style = "richtext";
            string url = String.Format("http://" + _server + "/dna/api/forums/ForumsService.svc/V1/site/{0}/forums/{1}/threads/{2}",
                _sitename, forum, thread);

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.AssertWebRequestFailure = false;

            request.SetCurrentUserBanned();

            string serializedData = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?><threadPost xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.datacontract.org/2004/07/BBC.Dna.Objects""><datePosted i:nil=""true"" /><firstChild>0</firstChild><inReplyTo>{0}</inReplyTo><inReplyToIndex>0</inReplyToIndex><index>0</index><nextIndex>0</nextIndex><nextSibling>0</nextSibling><postId>0</postId><prevIndex>0</prevIndex><prevSibling>0</prevSibling><status>0</status><style>{3}</style><subject>{1}</subject><text>{2}</text><threadId>0</threadId><user i:nil=""true"" /></threadPost>",
             inReplyTo,
             subject,
             text,
             style);

            try
            {
                request.RequestPageWithFullURL(url, serializedData, "text/xml");
            }
            catch (WebException)
            {

            }
            Assert.AreEqual(HttpStatusCode.Unauthorized, request.CurrentWebResponse.StatusCode);
            ErrorData errorData = (ErrorData)StringUtils.DeserializeObject(request.GetLastResponseAsXML().OuterXml, typeof(ErrorData));
            Assert.AreEqual(ErrorType.UserIsBanned.ToString(), errorData.Code);

            Console.WriteLine("After CreateForumPost_WithBannedUser_ThrowsException");
        }
        public void ReadAs_BannedUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);

            string forumId = testUtils_CommentsAPI.makeTestCommentForum();
            string commentID = testUtils_CommentsAPI.makeTestComment(forumId);

            markComment(commentID);

            myRequest.SetCurrentUserBanned();

            // now read it
            string url = String.Format(
                "http://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/commentsforums/{2}/?filterBy=EditorPicks",
                testUtils_CommentsAPI.server, testUtils_CommentsAPI.sitename, forumId
                );
            try
            {
                myRequest.RequestPageWithFullURL(url);
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.OK,
                "Failed listing editor's picks. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_CommentsAPI._schemaCommentForum);
            myValidator.Validate();
        }
        public void CreateAs_BannedUser()
        {
            XmlDocument xml;
            DnaXmlValidator myValidator;
            DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);

            string forumId = testUtils_CommentsAPI.makeTestCommentForum();
            string commentID = testUtils_CommentsAPI.makeTestComment(forumId);

            string url = String.Format(
                "http://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/comments/{2}/editorpicks/",
                testUtils_CommentsAPI.server, testUtils_CommentsAPI.sitename, commentID
                );
            string postData = testUtils_CommentsAPI.makeTimeStamp(); // needs some sort of post data otherwise it uses GET

            myRequest.SetCurrentUserBanned();

            try
            {
                myRequest.RequestPageWithFullURL(url, postData, "text/xml");
            }
            catch { }

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized,
                "Should have been unauthorised. Got: " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            xml = myRequest.GetLastResponseAsXML();
            myValidator = new DnaXmlValidator(xml.InnerXml, testUtils_CommentsAPI._schemaError);
            myValidator.Validate();
        }
Exemple #11
0
        public void PostToForum_UserIsBanned_CorrectError()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserBanned();
            var url = String.Format("PostToForum?skin=purexml&forumid=150");


            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("threadid", "33"));
            postParams.Enqueue(new KeyValuePair<string, string>("inreplyto", "60"));
            postParams.Enqueue(new KeyValuePair<string, string>("dnapoststyle", "1"));
            postParams.Enqueue(new KeyValuePair<string, string>("forum", "150"));
            postParams.Enqueue(new KeyValuePair<string, string>("subject", "test post"));
            postParams.Enqueue(new KeyValuePair<string, string>("body", "Post message"));
            postParams.Enqueue(new KeyValuePair<string, string>("post", "Post message"));

            try
            {
                request.RequestPage(url, postParams);
            }
            catch { }
            
            var xml = request.GetLastResponseAsXML();

            Assert.IsNotNull(xml.SelectSingleNode("//H2G2/POSTTHREADUNREG"));
            Assert.AreEqual("1", xml.SelectSingleNode("//H2G2/POSTTHREADUNREG").Attributes["RESTRICTED"].Value);
        }