public void bbActivateBoard() { aaCreateTopic(); Console.WriteLine("Before bbActivateBoard"); //Activate Board string url = "Messageboardadmin?cmd=activateboard&skin=purexml"; DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay"); urlRequest.SetCurrentUserEditor(); urlRequest.UseEditorAuthentication = true; urlRequest.RequestPage(url); XmlDocument doc = urlRequest.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("/H2G2[BOARDACTIVATED='1']"), "Check Board Activated"); url = "frontpage?skin=purexml"; urlRequest.RequestPage(url); doc = urlRequest.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']"), "Check topic published"); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TOPICLINKID='" + topicPreviewID + "']"), "Check Preview Topic Link"); XmlNode node = doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']/FORUMID"); if (node != null) { topicForumID = node.InnerText; } //Check Topic Forum Is Writable. url = "F" + topicForumID + "&skin=purexml"; urlRequest.RequestPage(url); doc = urlRequest.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMSOURCE/ARTICLE/ARTICLEINFO[FORUMID='" + topicForumID + "']"), "Check Topic ForumId"); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANREAD='1']"), "Check Read Permissions"); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANWRITE='1']"), "Check Write Permissions"); Console.WriteLine("After bbActivateBoard"); }
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 Messageboardschedule_CloseSiteInDB_CheckClosedInCSharp() { Console.WriteLine("TestCodeSignalSendToRecacheSiteListDataViaDotNet"); // Get the current open and close times for the h2g2 site DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.RequestPage("acs?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0"); // Now check to make sure that the XML for the sitelist has not changed request.RequestPage("?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0"); // Now set the site to be closed Assert.IsTrue(SetSiteEmergencyClosed(true), "Failed to close h2g2"); // Now check to make sure that the XML for the sitelist has not changed request.RequestPage("acs?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0"); // Now check to make sure that the XML for the sitelist has not changed request.RequestPage("?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0"); // Now send the recache signal and check to make sure that the times are updated! using (FullInputContext inputContext = new FullInputContext(false)) { inputContext.SendSignal("action=recache-site"); // Now check to make sure that the XML for the sitelist has not changed request.RequestPage("acs?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "1"); // Now check to make sure that the XML for the sitelist has not changed request.RequestPage("?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "1"); // Now set the site to be open Assert.IsTrue(SetSiteEmergencyClosed(false), "Failed to open h2g2"); // Double check to make sure it's back to normal // Now send the recache signal and check to make sure that the times are updated! inputContext.SendSignal("action=recache-site"); } // Now check to make sure that the closed value has been put back correctly request.RequestPage("acs?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0"); // Now check to make sure that the closed value has been put back correctly request.RequestPage("?skin=purexml"); Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null); Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0"); }
public void TestComplaintBannedEmailIsCaught() { // First make sure that the test user can make a complint before we put the email in the banned emails list DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.SetCurrentUserNormal(); int userID = request.CurrentUserID; request.RequestPage("UserComplaintPage?postid=2&skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); // Check to make sure that no errors came back Assert.IsTrue(xml.SelectSingleNode("//USER-COMPLAINT-FORM/ERROR") == null, "There should not be any errors present in the XML!"); try { // Now put the users email into the banned emails list for complaints IInputContext context = DnaMockery.CreateDatabaseInputContext(); using (IDnaDataReader reader = context.CreateDnaDataReader("AddEMailToBannedList")) { reader.AddParameter("Email", "*****@*****.**");//this is dotnetnormaluser's email reader.AddParameter("SigninBanned", 0); reader.AddParameter("ComplaintBanned", 1); reader.AddParameter("EditorID", 6); reader.AddIntReturnValue(); reader.Execute(); var duplicate = reader.GetIntReturnValue(); Assert.AreEqual(0, duplicate, "The Duplicate result should be false (0)"); request.RequestPage("dnasignal?action=recache-bannedEmails"); } // Now try to complain again request.RequestPage("UserComplaintPage?postid=2&skin=purexml"); request.SetCurrentUserEditor(); xml = request.GetLastResponseAsXML(); // Check to make sure that no errors came back Assert.IsTrue(xml.SelectSingleNode("//ERROR") != null, "There should be an error present in the XML!"); Assert.IsTrue(xml.SelectSingleNode("//ERROR[@TYPE='EMAILNOTALLOWED']") != null, "There should be an EMAILNOTALLOWED error present in the XML!"); } finally { IInputContext context = DnaMockery.CreateDatabaseInputContext(); using (IDnaDataReader reader = context.CreateDnaDataReader("")) { reader.ExecuteDEBUGONLY("exec removebannedemail @email='*****@*****.**'");//this is dotnetnormaluser's email request.RequestPage("dnasignal?action=recache-bannedEmails"); } } }
public void Setup() { using (FullInputContext inputcontext = new FullInputContext("")) { _appContext = new AppContext(TestConfig.GetConfig().GetRipleyServerPath()); _siteOptionList = new SiteOptionList(); _siteOptionList.CreateFromDatabase(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics); } DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); IInputContext inputContext = DnaMockery.CreateDatabaseInputContext(); using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader("")) { SetSiteID(dataReader, "h2g2"); _includeContentFromOtherSites = _siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites"); //Create a post on h2g2 SetForumID(dataReader); request = new DnaTestURLRequest("h2g2"); request.SetCurrentUserNormal(); int id = request.CurrentUserID; request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId)); //Create a post on have your say. SetSiteID(dataReader, "haveyoursay"); SetForumID(dataReader); request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); request.RequestPage("AddThread?subject=test&body=blahblah&post=1&skin=purexml&forum=" + Convert.ToString(_forumId)); } }
public void aaCreateTopic() { Console.WriteLine("Before aaCreateTopic"); topicName = "CreateTopic" + Convert.ToString(DateTime.Now.Ticks); string url = "TopicBuilder?_msfinish=yes&_msstage=1&_msxml=+%0D%0A%09%3CMULTI-INPUT%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TITLE%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXT%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXTTYPE%27+%3E%3C%2FREQUIRED%3E%09%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27TOPICID%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27EDITKEY%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%3C%2FMULTI-INPUT%3E%0D%0A+&cmd=create&title=" + topicName + "&text=TestBody" + topicName + "&save=+save++&skin=purexml"; DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay"); urlRequest.SetCurrentUserEditor(); urlRequest.UseEditorAuthentication = true; urlRequest.RequestPage(url); XmlDocument doc = urlRequest.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[TYPE='created']"),"Check Topic Creation"); Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[OBJECT='" + topicName + "']"),"Check Topic Creation"); Assert.IsNull(doc.SelectSingleNode("/H2G2/ERROR"),"Error in Page"); XmlNode node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/EDITKEY"); if ( node != null ) { topicEditKey = node.InnerText; } node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/TOPICID"); if ( node != null ) { topicPreviewID = node.InnerText; } Console.WriteLine("After aaCreateTopic"); }
public void SyncUserDetailsViaBBCDna() { DnaTestURLRequest request = new DnaTestURLRequest("identity606"); request.SetCurrentUserAsNewIdentityUser(_userName, _password, _displayName, _email, _dob, TestUserCreator.IdentityPolicies.Adult, "identity606", TestUserCreator.UserType.IdentityOnly); string cookie = request.CurrentCookie; request.RequestPage("status-n?skin=purexml"); XmlDocument doc = request.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME"), "User name is not correct"); Assert.AreEqual(_displayName, doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME").InnerText, "User name is not correct"); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME"), "login name is not correct"); Assert.AreEqual(_userName, doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME").InnerText, "login name is not correct"); Assert.IsNull(doc.SelectSingleNode("//VIEWING-USER/USER/FIRSTNAME"), "There shouldn't be a first name"); Assert.IsNull(doc.SelectSingleNode("//VIEWING-USER/LASTNAME"), "There shouldn't be a last name"); Thread.Sleep(2000); Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.DisplayName, _displayName)); Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.FirstName, _firstName)); Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.LastName, _lastName)); Assert.IsTrue(TestUserCreator.SetIdentityAttribute(_userName, cookie, TestUserCreator.AttributeNames.Email, _newEmail)); request.RequestPage("status-n?skin=purexml"); doc = request.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME"), "User name is not correct"); Assert.AreEqual(_displayName, doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME").InnerText, "User name is not correct"); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME"), "login name is not correct"); Assert.AreEqual(_userName, doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME").InnerText, "login name is not correct"); }
public void DuplicatePostParams() { Console.WriteLine("DuplicatePostParams"); DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); Queue<KeyValuePair<string, string>> postparams = new Queue<KeyValuePair<string, string> >(); postparams.Enqueue(new KeyValuePair<string,string>("s_param", "1,1")); postparams.Enqueue(new KeyValuePair<string,string>("s_param", "2,2")); postparams.Enqueue(new KeyValuePair<string,string>("s_param", "3,3")); request.RequestPage("acs?skin=purexml", postparams); string paramvalue = "1,1,2,2,3,3"; XmlDocument doc = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd"); validator.Validate(); validator = new DnaXmlValidator(doc.SelectSingleNode(@"H2G2/PARAMS").OuterXml, "Params.xsd"); validator.Validate(); XmlNodeList nodes = doc.SelectNodes(@"H2G2/PARAMS/PARAM"); foreach (XmlNode node in nodes) { Assert.AreEqual(paramvalue, node.SelectSingleNode("VALUE").InnerText); } }
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 EditPost_DoEdit_ReturnsEdittedPost() { DnaTestURLRequest request = new DnaTestURLRequest(_siteName); request.SetCurrentUserEditor(); var xml = GetPost(request, @"editpost?skin=purexml&postid=" + _postId.ToString()); Assert.IsNull(xml.SelectSingleNode("H2G2/ERROR")); Assert.IsNotNull(xml.SelectSingleNode("H2G2/POST-EDIT-FORM")); var editForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm)); Assert.AreEqual(_postId, editForm.PostId); var postParams = new Queue<KeyValuePair<string, string>>(); postParams = new Queue<KeyValuePair<string, string>>(); postParams.Enqueue(new KeyValuePair<string, string>("PostID", editForm.PostId.ToString())); postParams.Enqueue(new KeyValuePair<string, string>("Subject", editForm.Subject + "1")); postParams.Enqueue(new KeyValuePair<string, string>("Text", editForm.Text + "1")); postParams.Enqueue(new KeyValuePair<string, string>("Update", "Update")); postParams.Enqueue(new KeyValuePair<string, string>("hidePostReason", "")); postParams.Enqueue(new KeyValuePair<string, string>("notes", "test")); request.RequestPage("editpost?skin=purexml", false, postParams); xml = request.GetLastResponseAsXML(); var returnedForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm)); Assert.AreEqual(_postId, returnedForm.PostId); Assert.AreEqual(editForm.Subject + "1", returnedForm.Subject); Assert.AreEqual(editForm.Text + "1", returnedForm.Text); }
public void Test1CreateForumWithNoCloseDate() { Console.WriteLine("Before CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate"); // Create a new comment box with no closing date DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); // Setup the request url string uid = Guid.NewGuid().ToString(); string title = "Testing"; string hosturl = "http://local.bbc.co.uk/dna/haveyoursay/acs"; string url = "acs?dnauid=" + uid + "&dnainitialtitle=" + title + "&dnahostpageurl=" + hosturl + "&dnaforumduration=0&skin=purexml"; // now get the response request.RequestPage(url); // Check to make sure that the page returned with the correct information XmlDocument xml = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(xml.OuterXml, _schemaUri); validator.Validate(); Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null,"Comment box tag doers not exist!"); //Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE") != null,"End date missing when specified!"); Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@UID='" + uid + "']") != null, "Forums uid does not matched the one used to create!"); Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@HOSTPAGEURL='" + hosturl + "']") != null, "Host url does not match the one used to create!"); Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='1']") != null, "The forums can write flag should be set 1"); Console.WriteLine("After CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate"); }
public void Test2DuplicateComplaint() { DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); request.UseEditorAuthentication = false; request.RequestPage("UserComplaintPage?postid=" + Convert.ToString(_postId) + "&action=submit&complaintreason=libellous&complainttext=Complaint&skin=purexml"); //Check XML against Schema. XmlDocument doc = request.GetLastResponseAsXML(); Assert.IsTrue(doc.SelectSingleNode("//H2G2/USERCOMPLAINT/@MODID") != null, "Complaint should be processed"); String modId = doc.SelectSingleNode("//H2G2/USERCOMPLAINT/@MODID").Value; request.RequestPage("UserComplaintPage?postid=" + Convert.ToString(_postId) + "&action=submit&complaintreason=libellous&complainttext=Complaint&skin=purexml"); Assert.IsTrue(doc.SelectSingleNode("//H2G2/USERCOMPLAINT/@MODID") != null, "Complaint should be processed"); Assert.IsTrue(doc.SelectSingleNode("//H2G2/USERCOMPLAINT/@MODID").Value == modId, "New complaint should not be generated"); }
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 void TestModeratorManagementPageNonSuperuser() { DnaTestURLRequest request = new DnaTestURLRequest("moderation"); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage(@"ModeratorManagement?skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR")); }
public void TestModeratePostsPageNonModerator() { DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage(@"ModeratePosts?modclassid=1&skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR")); }
public void TestReturnKeyPhrasesInCategoryList() { Console.WriteLine("Before TestReturnKeyPhrasesInCategoryList"); // Connect to Actionnetwork and navigate to a known unhidden node DnaTestURLRequest request = new DnaTestURLRequest("actionnetwork"); request.SetCurrentUserNormal(); request.RequestPage("C36138?skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); Assert.IsTrue(xml.SelectSingleNode("//HIERARCHYDETAILS/REDIRECTNODEID") == null); Console.WriteLine("After TestReturnKeyPhrasesInCategoryList"); }
public void SiteOptions_ValidateSiteOptionsXMLFromBBCDNA_ExpectValid() { // Get the XML from the c# DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.RequestPage("Status-n?skin=purexml"); XmlDocument xDoc = request.GetLastResponseAsXML(); XmlElement siteoptions = (XmlElement)xDoc.SelectSingleNode("/H2G2/SITE/SITEOPTIONS"); Assert.IsNotNull(siteoptions, "Failed to get the site options from the XML"); DnaXmlValidator validator = new DnaXmlValidator(siteoptions, "SiteOptions.xsd"); validator.Validate(); }
public void TestAcsRequest() { DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.RequestPage(@"acs?dnatitle=New+Comment+Box2&dnaurl=http://local.bbc.co.uk:8000/testpage.shtml&dnauid=552F1F05-74AD-410b-880C-F37B83D8B69A&skin=purexml"); XmlDocument doc = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd"); validator.Validate(); Assert.IsTrue(doc.SelectSingleNode("/H2G2/SERVERNAME") != null, "No SERVERNAME element found"); Assert.IsTrue(doc.SelectSingleNode("/H2G2/TIMEFORPAGE") != null, "No TIMEFORPAGE element found"); Assert.IsTrue(doc.SelectSingleNode("/H2G2/USERAGENT") != null, "No USERAGENT element found"); }
public void UserList_AsNormalUser_ReturnsUnauthorised() { var request = new DnaTestURLRequest(_siteName); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage("userlist?skin=purexml"); var xml = request.GetLastResponseAsXML(); CheckForError(xml, "Authorization"); }
public void HostDashboardUserActivity_AsNormalUser_ReturnsUnauthorised() { var request = new DnaTestURLRequest(_siteName); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage(_normalUserSearch); var xml = request.GetLastResponseAsXML(); CheckForError(xml, "Authorization"); }
public void TestModerateHomePageNonSecure() { Console.WriteLine("Before moderationhome Page Tests - TestModerateHomePageNonSecure"); DnaTestURLRequest request = new DnaTestURLRequest("moderation"); request.SetCurrentUserEditor(); request.UseDebugUserSecureCookie = false; request.RequestPage(@"moderationhome?skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR")); Console.WriteLine("After moderationhome Page Tests - TestModerateHomePageNonSecure"); }
public void TestModerateHomePageNonModerator() { Console.WriteLine("Before moderationhome Page Tests - TestModerateHomePageNonModerator"); DnaTestURLRequest request = new DnaTestURLRequest("moderation"); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage(@"moderationhome?skin=purexml"); XmlDocument xml = request.GetLastResponseAsXML(); Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR")); Console.WriteLine("After moderationhome Page Tests - TestModerateHomePageNonModerator"); }
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 CheckCorrectUserDetailsViaBBCDnaWithDisplayName() { DnaTestURLRequest request = new DnaTestURLRequest("identity606"); request.SetCurrentUserAsNewIdentityUser(_userName, _password, _displayName, _email, _dob, TestUserCreator.IdentityPolicies.Adult, "identity606", TestUserCreator.UserType.IdentityOnly); request.RequestPage("status-n?skin=purexml"); XmlDocument doc = request.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME"), "User name is not correct"); Assert.AreEqual(_displayName, doc.SelectSingleNode("//VIEWING-USER/USER/USERNAME").InnerText, "User name is not correct"); Assert.IsNotNull(doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME"), "login name is not correct"); Assert.AreEqual(_userName, doc.SelectSingleNode("//VIEWING-USER/SIGNINNAME").InnerText, "login name is not correct"); }
public void Messageboardschedule_SetInRipley_CheckVisibleInCSharp() { // Fill the times dictionary with the current open close times for h2g2 // Get the current open and close times for the h2g2 site DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.RequestPage("acs?skin=purexml"); // Check to see if we've got openclose times for this site Assert.IsNull(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/OPENCLOSETIMES/OPENCLOSETIME")); // no times! Set daily repeating times for the site request.UseEditorAuthentication = true; request.SignUserIntoSSOViaProfileAPI(DnaTestURLRequest.usertype.EDITOR); request.RequestPage("messageboardschedule?action=update&updatetype=sameeveryday&recurrenteventopenhours=0&recurrenteventopenminutes=15&recurrenteventclosehours=23&recurrenteventcloseminutes=45&skin=purexml"); request.UseEditorAuthentication = false; // Now re-request the original page request.RequestPage("acs?skin=purexml"); Assert.IsNotNull(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/OPENCLOSETIMES/OPENCLOSETIME")); }
public void TermsFilterAdminPage_WithEditorAuthenticationAsEditor_AccessDenied() { var siteName = "moderation"; var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = true }; request.SetCurrentUserEditor(); request.RequestPage("termsfilteradmin?modclassid=2&skin=purexml"); var doc = request.GetLastResponseAsXML(); Assert.AreEqual("ERROR",doc.SelectSingleNode("//H2G2").Attributes["TYPE"].Value); Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR/ERRORMESSAGE")); Assert.IsNull(doc.SelectSingleNode("//H2G2/TERMADMIN")); }
public void TermsFilterImportPage_WithEditorAuthenticationAsEditor_AccessDenied() { var siteName = "moderation"; var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = true }; request.SetCurrentUserEditor(); request.RequestPage("termsfilterimport?&skin=purexml"); var doc = request.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR")); Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR/ERRORMESSAGE")); Assert.IsNull(doc.SelectSingleNode("//H2G2/TERMADMIN")); }
public void TestXSLTCaching() { Console.WriteLine("Before TestXSLTCaching"); // First log the user into the system. DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.SetCurrentUserEditor(); // Now create the test skin to use StreamWriter test1file = new StreamWriter(_testXSLTFilename); test1file.Write(CreateXSLTFile("XSLT caching test 1")); test1file.Close(); // Now call the acs page with the clear templates flag and // check to make sure that it returns the text we supplied in the new xslt file. request.RequestPage("acs?d_skinfile=" + _testXSLTFilename + "&clear_templates=1"); Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 1")); // Now update the file so that it says something different. StreamWriter test2file = new StreamWriter(_testXSLTFilename); test2file.Flush(); test2file.Write(CreateXSLTFile("XSLT caching test 2")); test2file.Close(); // Now call the same page. We should still have the old transform in cache, so the text should still reflect what was in the old file! request.RequestPage("acs?d_skinfile=" + _testXSLTFilename); Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 1")); // Now call the acs page and flush the cache. We should now see that it is using the new file and not the old! request.RequestPage("acs?d_skinfile=" + _testXSLTFilename + "&clear_templates=1"); Assert.IsFalse(request.GetLastResponseAsString().Contains("XSLT caching test 1")); Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 2")); // Now delete the file totally! Check to make sure we still have the cached version! File.Delete(_testXSLTFilename); request.RequestPage("acs?d_skinfile=" + _testXSLTFilename); Assert.IsFalse(request.GetLastResponseAsString().Contains("XSLT caching test 1")); Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 2")); Console.WriteLine("After TestXSLTCaching"); }
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(); }