public void MakeUserEditorOfSite()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.SetCurrentUserSuperUser();

            DnaTestURLRequest request2 = new DnaTestURLRequest("moderation");
            request2.SetCurrentUserNormal();

            request.UseEditorAuthentication = true;
            request.RequestPage(String.Format("ModeratorManagement?manage=editor&giveaccess=1&userid={0}&siteid={1}&skin=purexml",request2.CurrentUserID,_siteId) );

            //Check user is editor of site concerned.
            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.IsNotNull(xml.SelectSingleNode("/H2G2/MODERATOR-LIST[@GROUPNAME='editor']"));
            XmlNode node = xml.SelectSingleNode(String.Format("/H2G2/MODERATOR-LIST/MODERATOR[USER/USERID={0}]/SITES/SITE[@SITEID={1}]",request2.CurrentUserID,_siteId) );
            Assert.IsNotNull(node);

            
            CheckUserPermissions("EDITOR");
            

            //Remove Access
            request.RequestPage(String.Format("ModeratorManagement?manage=editor&removeaccess=1&userid={0}&siteid={1}&skin=purexml", request2.CurrentUserID, 1));
            xml = request.GetLastResponseAsXML();
            node = xml.SelectSingleNode(String.Format("/H2G2/MODERATOR-LIST/MODERATOR[USER/USERID={0}]/SITES/SITE[@SITEID={1}]", request2.CurrentUserID, 1));
            Assert.IsNull(node);
        }
        public void TermsFilterAdminPage_UpdateExistingTerm_CorrectlyUpdates()
        {
            const int modClassId = 2;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termText = termNode.Attributes["TERM"].Value;
            var action = (TermAction) Enum.Parse(typeof (TermAction), termNode.Attributes["ACTION"].Value);
            TermAction expectedAction = (action == TermAction.ReEdit ? TermAction.Refer : TermAction.ReEdit);

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext",termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&action=UPDATETERM&skin=purexml", modClassId),
                postParams);

            ValidateResponse(request);
            ValidateOkResult(request, "TermsUpdateSuccess", "Terms updated successfully.");
            doc = request.GetLastResponseAsXML();
            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            Assert.AreEqual(expectedAction.ToString(), termNode.Attributes["ACTION"].Value);
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value);

            //check history audit
            var terms = new List<Term>();
            terms.Add(new Term { Id = Int32.Parse(termNode.Attributes["ID"].Value), Action = expectedAction});
            CheckAuditTable(modClassId, terms);

        }
 public void TermsFilterAdminPage_AsSuperUser_PassesValidation()
 {
     
     var request = new DnaTestURLRequest(SiteName) {UseEditorAuthentication = true};
     request.SetCurrentUserSuperUser();
     request.RequestPage("termsfilteradmin?modclassid=2&skin=purexml");
     ValidateResponse(request);
 }
 public void TermsFilterImportPage_WithoutEditorAuthenticationAsInSecured_AccessDenied()
 {
     var siteName = "moderation";
     var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = false, UseDebugUserSecureCookie=false};
     request.SetCurrentUserSuperUser();
     request.RequestPage("termsfilterimport?&skin=purexml", false, null);
     var xml = request.GetLastResponseAsXML();
     Assert.AreEqual("ERROR", xml.DocumentElement.Attributes[0].Value);
 }
 public static void SetSiteOptionForAnonymousPosting(DnaTestURLRequest request, bool allow)
 {
     request.SetCurrentUserSuperUser();
     string requestURL = "SiteOptions?siteid=1&so_1_CommentForum_AllowNotSignedInCommenting=1&sov_1_CommentForum_AllowNotSignedInCommenting=";
     requestURL += allow ? "1" : "0";
     requestURL += "&cmd=update&skin=purexml";
     request.RequestSecurePage(requestURL);
     Thread.Sleep(3000);
 }
Exemple #6
0
        public void superUser()
        {
            Console.WriteLine("Before userTypes - superUser");

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

            doIt_xml(request, HttpStatusCode.OK);

            Console.WriteLine("After userTypes - superUser");
        }
Exemple #7
0
        public void SiteManager_GetKnownSite_ReturnsCorrectXML()
        {
            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication= true;

            request.RequestPage("sitemanager?skin=purexml");

            var xmlDoc = request.GetLastResponseAsXML();
            ValidateSiteManagerPage(xmlDoc);
           
        }
        public void TestModeratorManagementPageXml()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(@"ModeratorManagement?skin=purexml");

            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("H2G2") != null, "The page does not exist!!!");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, "H2G2ModeratorManagementPage.xsd");
            validator.Validate();
        }
        public void TermsFilterAdminPage_WithoutEditorAuthentication_AccessDenied()
        {
            var siteName = "moderation";
            var request = new DnaTestURLRequest(siteName) {UseEditorAuthentication = false};
            request.SetCurrentUserSuperUser();
            bool exceptionThrown=false;
            try
            {
                request.RequestPage("termsfilteradmin?modclassid=2&skin=purexml");
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
        public void TermsFilterImportPage_WithoutEditorAuthenticationAsSecure_NoError()
        {
            var siteName = "moderation";
            var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = false};
            request.SetCurrentUserSuperUser();
            bool exceptionThrown = false;
            try
            {
                request.RequestPage("termsfilterimport?&skin=purexml", true, null);
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsFalse(exceptionThrown);
        }
        public void GivenIamASuperUser_WhenICreateATwitterProfileWithValidData_ThenMyProfileIsCreatedSuccessfully()
        {
            var dnaRequest = new DnaTestURLRequest("moderation");

            dnaRequest.SetCurrentUserSuperUser();

            const string url = "admin/twitterprofile?sitename=&s_sitename=All&profileid=blah&title=blah&commentforumparenturl=blah&users=blah+&searchterms=blah+&moderated=true&action=createupdateprofile&skin=purexml";

            dnaRequest.UseProxyPassing = false;

            dnaRequest.RequestPage(url);

            const string xpath = @"/H2G2/ERROR[@TYPE=""TWITTERPROFILEMANDATORYFIELDSMISSING""]/ERRORMESSAGE";

            var response = dnaRequest.GetLastResponseAsXML();

            Assert.IsNull(response.SelectSingleNode(xpath));
        }
        public void GivenIamASuperUser_WhenICreateATwitterProfile_WithABlankTitle_ThenIamShownTheMissingTitleErrorMessage()
        {
            var dnaRequest = new DnaTestURLRequest("moderation");

            dnaRequest.SetCurrentUserSuperUser();

            const string url = "admin/twitterprofile?sitename=&s_sitename=h2g2&profileid=blahblah&title=&commentforumparenturl=blah&users=blah+&searchterms=blah+&moderated=true&action=createupdateprofile&skin=purexml";

            dnaRequest.UseProxyPassing = false;

            dnaRequest.RequestPage(url);

            var response = dnaRequest.GetLastResponseAsXML();

            const string xpath = @"/H2G2/ERROR[@TYPE=""TWITTERPROFILEMANDATORYFIELDSMISSING""]/ERRORMESSAGE";

            const string expected = "Please fill in the mandatory fields for creating/updating a profile";

            var actual = response.SelectSingleNode(xpath).InnerXml;

            Assert.AreEqual(expected, actual);
        }
Exemple #13
0
        protected static string CallAPIRequest(DnaTestURLRequest request, string requestURL, string postData, DnaTestURLRequest.usertype userType, string requestMethod)
        {
            if (userType == DnaTestURLRequest.usertype.SUPERUSER)
            {
                request.SetCurrentUserSuperUser();
            } 
            else if (userType == DnaTestURLRequest.usertype.EDITOR)
            {
                request.SetCurrentUserEditor();
            }
            else if (userType == DnaTestURLRequest.usertype.NORMALUSER)
            {
                request.SetCurrentUserNormal();
            }
            else
            {
                request.SetCurrentUserNotLoggedInUser();
            }

            request.AssertWebRequestFailure = false;
            request.RequestPageWithFullURL(requestURL, postData, "application/json", requestMethod);
            return requestURL;
        }
Exemple #14
0
        public void UserList_RemovePostsE2EWithMBs_ReturnsCorrectResults()
        {
            //check existing forum
            var request = new DnaTestURLRequest("h2g2");
            request.RequestPage(string.Format("NF{0}?thread={1}&skin=purexml", 150, 32));
            var xml = request.GetLastResponseAsXML();

            var posts = xml.SelectNodes("//H2G2/FORUMTHREADPOSTS/POST");
            foreach (XmlNode post in posts)
            {
                if (post.SelectSingleNode("USER/USERID").InnerText == _normalUserId.ToString())
                {
                    Assert.AreNotEqual("8", post.Attributes["HIDDEN"].InnerText);
                }
            }

            //Deactivated user
            var newModStatus = "Deactivated";
            var newDuration = "0";
            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));
            postData.Enqueue(new KeyValuePair<string, string>("hideAllPosts", "1"));
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);
            xml = request.GetLastResponseAsXML();
            CheckValidXml(xml, true);
            CheckUpdateApplied(xml, newModStatus, newDuration, true, _siteId);

            //check posts are hidden
            request.RequestPage(string.Format("NF{0}?thread={1}&skin=purexml", 150, 32));
            xml = request.GetLastResponseAsXML();

            posts = xml.SelectNodes("//H2G2/FORUMTHREADPOSTS/POST");
            foreach (XmlNode post in posts)
            {
                if (post.SelectSingleNode("USER/USERID").InnerText == _normalUserId.ToString())
                {
                    Assert.AreEqual("8", post.Attributes["HIDDEN"].InnerText);
                }
            }

            //reactivate user
            newModStatus = "Standard";
            newDuration = "0";
            applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);
            xml = request.GetLastResponseAsXML();
            CheckValidXml(xml, true);
            CheckUpdateApplied(xml, newModStatus, newDuration);

            //check posts are unhidden
            request.RequestPage(string.Format("NF{0}?thread={1}&skin=purexml", 150, 32));
            xml = request.GetLastResponseAsXML();

            posts = xml.SelectNodes("//H2G2/FORUMTHREADPOSTS/POST");
            foreach (XmlNode post in posts)
            {
                if (post.SelectSingleNode("USER/USERID").InnerText == _normalUserId.ToString())
                {
                    Assert.AreNotEqual("8", post.Attributes["HIDDEN"].InnerText);
                }
            }
        }
Exemple #15
0
        public void UserList_SetMultipleBanned_ReturnsCorrectResults()
        {
            var newModStatus = "Restricted";
            var newDuration = "0";
            var secondSite = 54;

            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            var applyKey2 = string.Format("applyTo|{0}|{1}", _normalUserId, secondSite);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>(applyKey2, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("additionalNotes", "additionalNotes"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));



            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);

            var xml = request.GetLastResponseAsXML();

            CheckValidXml(xml, true);

            CheckUpdateApplied(xml, "Restricted", newDuration);
            CheckUpdateApplied(xml, "Restricted", newDuration, false, secondSite);

            using (IDnaDataReader reader = testContext.CreateDnaDataReader(""))
            {
                reader.ExecuteDEBUGONLY("select * from UserPrefStatusAudit where userid=" + TestUserAccounts.GetSuperUserAccount.UserID + " and userupdateid in (select max(UserUpdateId) from UserPrefStatusAudit)");
                Assert.IsTrue(reader.Read());
                Assert.AreEqual("test - additionalNotes", reader.GetString("Reason"));
            }
        }
Exemple #16
0
        public void UserList_SetBannedWithoutReason_ReturnsError()
        {
            var newModStatus = "Restricted";
            var newDuration = "0";

            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            //postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));


            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);

            var xml = request.GetLastResponseAsXML();

            CheckForError(xml, "EmptyReason");
        }
Exemple #17
0
        public void UserList_SetDeactivatedWithRemoveContent_ReturnsCorrectResults()
        {
            var newModStatus = "Deactivated";
            var newDuration = "0";
            var removeContent =true;

            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));
            postData.Enqueue(new KeyValuePair<string, string>("hideAllPosts", "1"));

            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);

            var xml = request.GetLastResponseAsXML();

            CheckValidXml(xml, true);

            CheckUpdateApplied(xml, newModStatus, newDuration, removeContent, _siteId);
        }
Exemple #18
0
        public void UserList_SetDeactivated_ReturnsCorrectResults()
        {
            var newModStatus = "Deactivated";
            var newDuration = "0";

            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));



            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);

            var xml = request.GetLastResponseAsXML();

            CheckValidXml(xml, true);

            CheckUpdateApplied(xml, newModStatus, newDuration);

            //c# test
            request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserNormal();
            request.RequestPage("mbfrontpage?skin=purexml");
            xml =request.GetLastResponseAsXML();
            Assert.IsNull(xml.SelectSingleNode("//H2G2/VIEWING-USER/USER"));

            //c++ test
            request.RequestPage("home?skin=purexml");
            xml = request.GetLastResponseAsXML();
            Assert.IsNull(xml.SelectSingleNode("//H2G2/VIEWING-USER/USER"));
        }
Exemple #19
0
        public void UserList_SearchInvalidBBCUid_ReturnsCorrectError()
        {
            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;


            request.RequestPage(String.Format("userlist?searchText=notaguid&usersearchtype=4&skin=purexml"));

            var xml = request.GetLastResponseAsXML();

            CheckForError(xml, "NotValidBBCUid");
        }
        public void TermsFilterAdminPage_CreateGreekTermRefreshSitePostViaAcs_CorrectlyBlocksContent()
        {
            const int modClassId = 3;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml&ignorecache=1", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termNodeCount = doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count;
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            var termText = "πρόσωπο";
            TermAction expectedAction = TermAction.ReEdit;

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext", termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&action=UPDATETERM&skin=purexml", modClassId),
                postParams);

            ValidateResponse(request);
            ValidateOkResult(request, "TermsUpdateSuccess", "Terms updated successfully.");
            doc = request.GetLastResponseAsXML();
            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS[@TERM='" + termText + "']");
            Assert.AreEqual(expectedAction.ToString(), termNode.Attributes["ACTION"].Value);
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value);
            Assert.AreEqual(termNodeCount + 1, doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count);

            //check history audit
            var terms = new List<Term>();
            terms.Add(new Term { Id = Int32.Parse(termNode.Attributes["ID"].Value), Action = expectedAction });
            CheckAuditTable(modClassId, terms);

            //Do siterefresh
            request.RequestPage("termsfilteradmin?action=REFRESHCACHE");

            // Setup the request url
            var url = String.Format("acs?dnauid={0}&dnahostpageurl={1}&dnainitialtitle={2}&dnaur=0&skin=purexml", 
                Guid.NewGuid(), "http://www.bbc.co.uk/dna/h2g2/test.aspx", "test forum");
            // now get the response
            request = new DnaTestURLRequest("h2g2");
            request.SetCurrentUserNormal();
            request.RequestPage(url);//create forum
            doc = request.GetLastResponseAsXML();
            Assert.IsNull(doc.SelectSingleNode("//H2G2/ERROR"));

            url += "&dnaaction=add";
            postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("dnacomment", termText));
            request.RequestSecurePage(url, postParams);
            ValidateError(request, "profanityblocked", termText);


        }
Exemple #21
0
        public void UserList_SearchTwitterUserName_ReturnsException()
        {
            var twitterSearchName = "_DotNetNormalUser";

            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;

            _twitterUserScreenName = _twitterUserScreenName.Replace("twittersearch", twitterSearchName);

            request.RequestPage(_twitterUserScreenName);

            var xml = request.GetLastResponseAsXML();

            var expectedTwitterError = "Searched user not found in Twitter";

            var expectedTwitterException = "Twitter Exception: The remote server returned an unexpected response: (400) Bad Request. Please try again in few minutes.";

            if (true == xml.SelectSingleNode("//H2G2/MEMBERLIST").Attributes["TWITTEREXCEPTION"].Value.Contains("Twitter Exception:"))
            {
                Assert.AreEqual(expectedTwitterException, xml.SelectSingleNode("//H2G2/MEMBERLIST").Attributes["TWITTEREXCEPTION"].Value);
            }
            else
            {
                Assert.AreEqual(expectedTwitterError, xml.SelectSingleNode("//H2G2/MEMBERLIST").Attributes["TWITTEREXCEPTION"].Value);
            }
            
        }
Exemple #22
0
        public void UserList_SearchTwitterUserName_ReturnsCorrectResults()
        {
            var twitterSearchName = "FurryGeezer";

            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;

            _twitterUserScreenName = _twitterUserScreenName.Replace("twittersearch", twitterSearchName);

            request.RequestPage(_twitterUserScreenName);

            var xml = request.GetLastResponseAsXML();

            if (string.IsNullOrEmpty(xml.SelectSingleNode("//H2G2/MEMBERLIST").Attributes["TWITTEREXCEPTION"].Value))
            {
                Assert.AreEqual(xml.SelectSingleNode("//H2G2/MEMBERLIST/USERACCOUNTS/USERACCOUNT/LOGINNAME").InnerXml, twitterSearchName);
            }
            else
            {
                var expectedTwitterException = "Twitter Exception: The remote server returned an unexpected response: (400) Bad Request. Please try again in few minutes.";

                Assert.AreEqual(xml.SelectSingleNode("//H2G2/MEMBERLIST").Attributes["TWITTEREXCEPTION"].Value, expectedTwitterException);
            }
        }
Exemple #23
0
        public void UserList_SearchNormalUserName_ReturnsCorrectResults()
        {
            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;

            request.RequestPage(_normalUserSearch);

            var xml = request.GetLastResponseAsXML();

            CheckValidXml(xml, true);
        }
Exemple #24
0
        public void CreateCommentForum_CreateCommentAsNonAgreedTermsAndConditionsUser()
        {
            Console.WriteLine("Before CreateCommentAsNonAgreedTermsAndConditionsUser");

            var request = new DnaTestURLRequest("identity606");

            string userName = "******" + DateTime.Now.Ticks;
            string userEmail = userName + "@bbc.co.uk";
            request.SetCurrentUserSuperUser();
            /*
            Assert.IsTrue(
                request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31",
                                                        TestUserCreator.IdentityPolicies.Adult, "identity606",
                                                        TestUserCreator.UserType.SuperUser),
                "Failed to create a test identity user");
            */
            string id = "FunctiontestCommentForum-" + Guid.NewGuid(); //have to randomize the string to post
            string title = "Functiontest Title";
            string parentUri = "http://www.bbc.co.uk/dna/h2g2/";
            string commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
                                                   "<id>{0}</id>" +
                                                   "<title>{1}</title>" +
                                                   "<parentUri>{2}</parentUri>" +
                                                   "</commentForum>", id, title, parentUri);

            // Setup the request url
            string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
                                       "identity606");

            try
            {
                // now get the response
                request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            }
            catch
            {
            }
            ;

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK);

            userName = "******" + DateTime.Now.Ticks;
            userEmail = userName + "@bbc.co.uk";
            //Assert.IsTrue(request.SetCurrentUserAsNewIdentityUser(userName, "password", "Comment User", userEmail, "1989-12-31", TestUserCreator.IdentityPolicies.Adult, true, false, 1, false), "Failed to create a test identity user");

            Cookie cookie;
            Cookie secureCookie;
            string identityUserID;
            Assert.IsTrue(TestUserCreator.CreateIdentityUser(userName, "password", "1989-12-31", userEmail,
                                                             "Comment User", true,
                                                             TestUserCreator.IdentityPolicies.Adult, false, 0,
                                                             out cookie,
                                                             out secureCookie,
                                                             out identityUserID));

            request.UseDebugUser = false;
            request.ClearCookieContainer();
            request.UseIdentitySignIn = true;

            request.CurrentCookie = cookie.Value;
            request.CurrentSecureCookie = secureCookie.Value;

            string text = "Functiontest Title" + Guid.NewGuid();
            commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                                            "<text>{0}</text>" +
                                            "</comment>", text);

            // Setup the comment request url - needs to be secure
            url =
                String.Format(
                    "https://" + _secureServer + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/",
                    "identity606", id);

            try
            {
                // now get the response
                request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            }
            catch
            {
            }
            ;

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.Unauthorized);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();

            var nsmgr = new XmlNamespaceManager(xml.NameTable);
            nsmgr.AddNamespace("bda", "BBC.Dna.Api");
            Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:code", nsmgr), "Failed to find the error code");
            Assert.AreEqual("FailedTermsAndConditions", xml.SelectSingleNode("//bda:error/bda:code", nsmgr).InnerText);
            Assert.IsNotNull(xml.SelectSingleNode("//bda:error/bda:detail", nsmgr), "Failed to find the error deatils");
            Assert.AreEqual("comment",
                            xml.SelectSingleNode("//bda:error/bda:detail", nsmgr).InnerText);

            Console.WriteLine("After CreateCommentAsNonAgreedTermsAndConditionsUser");
        }
        public void TermsFilterAdminPage_UpdateExistingTermMissingModClassId_CorrectError()
        {
            const int modClassId = 1;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termText = termNode.Attributes["TERM"].Value;
            var action = (TermAction)Enum.Parse(typeof(TermAction), termNode.Attributes["ACTION"].Value);
            TermAction expectedAction = (action == TermAction.ReEdit ? TermAction.Refer : TermAction.ReEdit);

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext", termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?action=UPDATETERM&skin=purexml"),
                postParams);

            doc = request.GetLastResponseAsXML();
            ValidateError(request, "UPDATETERM", "Moderation Class ID cannot be 0.");

            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            Assert.AreEqual(action.ToString(), termNode.Attributes["ACTION"].Value);//should not have changed
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value);
        }
        public void TermsFilterAdminPage_CreateTermRefreshSitePostViaApi_CorrectlyBlocksContent()
        {
            const int modClassId = 3;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml&ignorecache=1", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termNodeCount = doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count;
            var termText = "你好";
            TermAction expectedAction = TermAction.ReEdit;

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext", termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&action=UPDATETERM&skin=purexml", modClassId),
                postParams);

            ValidateResponse(request);
            ValidateOkResult(request, "TermsUpdateSuccess", "Terms updated successfully.");
            doc = request.GetLastResponseAsXML();
            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS[@TERM='" + termText + "']");
            Assert.AreEqual(expectedAction.ToString(), termNode.Attributes["ACTION"].Value);
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value);
            Assert.AreEqual(termNodeCount + 1, doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count);

            //check history audit
            var terms = new List<Term>();
            terms.Add(new Term { Id = Int32.Parse(termNode.Attributes["ID"].Value), Action = expectedAction });
            CheckAuditTable(modClassId, terms);

            //Do siterefresh
            request.RequestPage("termsfilteradmin?action=REFRESHCACHE");

            //Post Via Comments Api
            var commentForumObj = new CommentForumTests_V1();
            var commentForum = commentForumObj.CommentForumCreateHelper();
            var commentXml = String.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?><comment xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text>" +
                "</comment>", termText);

            // Setup the request url
            var url = String.Format("https://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/commentsforums/{2}/", DnaTestURLRequest.SecureServerAddress, commentForum.SiteName, commentForum.Id);
            // now get the response
            request = new DnaTestURLRequest(commentForum.SiteName);
            request.SetCurrentUserNormal();
            var exceptionThrown = false;
            try
            {
                request.RequestPageWithFullURL(url, commentXml, "text/xml");

            }
            catch (Exception)
            {
                exceptionThrown = true;
                Assert.AreEqual(HttpStatusCode.BadRequest, request.CurrentWebResponse.StatusCode);
            }
            Assert.IsTrue(exceptionThrown);
            


        }
Exemple #27
0
        public void UserList_RemovePostsE2EWithCommentsApi_ReturnsCorrectResults()
        {
            //check existing forum
            string commentForumUrl = string.Format("http://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/commentsforums/{2}/",
                    DnaTestURLRequest.CurrentServer, "h2g2", "TestUniqueKeyValue");
            
            var request = new DnaTestURLRequest("h2g2");
            request.RequestPageWithFullURL(commentForumUrl);
            var xml = request.GetLastResponseAsXML();

            var commentForum = (CommentForum)StringUtils.DeserializeObject(xml.OuterXml, typeof(CommentForum));
            foreach (var post in commentForum.commentList.comments)
            {
                Assert.AreNotEqual(CommentStatus.Hidden.Removed_UserContentRemoved, post.hidden);
            }

            //Deactivated user
            var newModStatus = "Deactivated";
            var newDuration = "0";
            var applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            Queue<KeyValuePair<string, string>> postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));
            postData.Enqueue(new KeyValuePair<string, string>("hideAllPosts", "1"));
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);
            xml = request.GetLastResponseAsXML();
            CheckValidXml(xml, true);
            CheckUpdateApplied(xml, newModStatus, newDuration, true, _siteId);

            //check posts are hidden
            request.RequestPageWithFullURL(commentForumUrl);
            xml = request.GetLastResponseAsXML();

            commentForum = (CommentForum)StringUtils.DeserializeObject(xml.OuterXml, typeof(CommentForum));
            foreach (var post in commentForum.commentList.comments)
            {
                Assert.AreEqual(CommentStatus.Hidden.Removed_UserContentRemoved, post.hidden);
            }

            //reactivate user
            newModStatus = "Standard";
            newDuration = "0";
            applyKey = string.Format("applyTo|{0}|{1}", _normalUserId, _siteId);
            postData = new Queue<KeyValuePair<string, string>>();
            postData.Enqueue(new KeyValuePair<string, string>(applyKey, ""));
            postData.Enqueue(new KeyValuePair<string, string>("userStatusDescription", newModStatus));
            postData.Enqueue(new KeyValuePair<string, string>("duration", newDuration));
            postData.Enqueue(new KeyValuePair<string, string>("reasonChange", "test"));
            postData.Enqueue(new KeyValuePair<string, string>("ApplyAction", "1"));
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(_normalUserSearch, postData);
            xml = request.GetLastResponseAsXML();
            CheckValidXml(xml, true);
            CheckUpdateApplied(xml, newModStatus, newDuration);

            //check posts are unhidden
            request.RequestPageWithFullURL(commentForumUrl);
            xml = request.GetLastResponseAsXML();

            commentForum = (CommentForum)StringUtils.DeserializeObject(xml.OuterXml, typeof(CommentForum));
            foreach (var post in commentForum.commentList.comments)
            {
                Assert.AreNotEqual(CommentStatus.Hidden.Removed_UserContentRemoved, post.hidden);
            }
        }
Exemple #28
0
        public void UserList_SearchNormalUserBBCUid_ReturnsCorrectResults()
        {
            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;


            request.RequestPage(String.Format("userlist?searchText=00000000-0000-0000-0000-000000000000&usersearchtype=4&skin=purexml"));

            var xml = request.GetLastResponseAsXML();

            CheckValidXml(xml, true);
        }
Exemple #29
0
        public void UserList_AsSuperUser_ReturnsAuthorised()
        {
            var request = new DnaTestURLRequest(_siteName);
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage("userlist?skin=purexml");

            var xml = request.GetLastResponseAsXML();

            CheckNoError(xml);
        }
        public void TermsFilterAdminPage_CreateEnglishTermRefreshSitePostViaAddThread_CorrectlyBlocksContent()
        {
            const int modClassId = 3;
            var request = new DnaTestURLRequest(SiteName) { UseEditorAuthentication = true };
            request.SetCurrentUserSuperUser();
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            ValidateResponse(request);

            var doc = request.GetLastResponseAsXML();
            var termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS");
            var termNodeCount = doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count;
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&skin=purexml", modClassId));
            var termText = "testterm";
            TermAction expectedAction = TermAction.ReEdit;

            var postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("termtext", termText));
            postParams.Enqueue(new KeyValuePair<string, string>("termaction", expectedAction.ToString()));

            //update the first term
            request.RequestPage(string.Format("termsfilteradmin?modclassid={0}&action=UPDATETERM&skin=purexml", modClassId),
                postParams);

            ValidateResponse(request);
            ValidateOkResult(request, "TermsUpdateSuccess", "Terms updated successfully.");
            doc = request.GetLastResponseAsXML();
            termNode = doc.SelectSingleNode("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS[@TERM='" + termText + "']");
            Assert.AreEqual(expectedAction.ToString(), termNode.Attributes["ACTION"].Value);
            Assert.AreEqual(termText, termNode.Attributes["TERM"].Value );
            Assert.AreEqual(termNodeCount + 1, doc.SelectNodes("//H2G2/TERMSFILTERADMIN/TERMSLIST/TERMDETAILS").Count);

            //check history audit
            var terms = new List<Term>();
            terms.Add(new Term { Id = Int32.Parse(termNode.Attributes["ID"].Value), Action = expectedAction });
            CheckAuditTable(modClassId, terms);

            //Do siterefresh
            request.RequestPage("termsfilteradmin?action=REFRESHCACHE");

            // Setup the request url
            var url = String.Format("AddThread?skin=purexml");
            var newrequest = new DnaTestURLRequest("h2g2");
            newrequest.SetCurrentUserNormal();
            postParams = new Queue<KeyValuePair<string, string>>();
            postParams.Enqueue(new KeyValuePair<string, string>("threadid", "0"));
            postParams.Enqueue(new KeyValuePair<string, string>("inreplyto", "0"));
            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", termText));
            postParams.Enqueue(new KeyValuePair<string, string>("post", "Post message"));
            newrequest.RequestPage(url, postParams);
            doc = newrequest.GetLastResponseAsXML();
            //check for profanity triggered value
            Assert.IsNotNull(doc.SelectSingleNode("//H2G2/POSTTHREADFORM[@PROFANITYTRIGGERED='1']"));
        }