public void CreateAs_NormalUser() { 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(); // give it some sort of psot so that it uses POST, also see if it is interested in the POST data // create the pick myRequest.SetCurrentUserNormal(); 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(); }
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 static int runningForumCount = 0; // used to see our starting count, before we start adding forums. /// <summary> /// Simply count the number of commentsForums that have been created so far on this site /// </summary> /// <param name="SiteName">the name of the sute to query</param> /// <returns>teh count</returns> public static int countForums(string SiteName) { string _server = DnaTestURLRequest.CurrentServer; DnaTestURLRequest request = new DnaTestURLRequest(SiteName); request.SetCurrentUserNormal(); // Setup the request url string url = "http://" + _server + "/dna/api/comments/CommentsService.svc/v1/site/" + SiteName + "/"; // now get the response - no POST data, nor any clue about the input mime-type request.RequestPageWithFullURL(url, "", ""); Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK); XmlDocument xml = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList); validator.Validate(); BBC.Dna.Api.CommentForumList returnedList = (BBC.Dna.Api.CommentForumList)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.CommentForumList)); Assert.IsTrue(returnedList != null); return returnedList.TotalCount; }
public void GetForumSource_V1Xml_ReadOnly_Returns404() { Console.WriteLine("Before GetForumSource_V1Xml_ReadOnly_Returns404"); DnaTestURLRequest request = new DnaTestURLRequest(_sitename); request.SetCurrentUserNormal(); request.AssertWebRequestFailure = false; string url = String.Format("http://" + _server + "/dna/api/forums/ForumsService.svc/V1/site/{0}/forums/{1}/threads/{2}/forumsource?format=xml", _sitename, 666, 666); try { request.RequestPageWithFullURL(url, null, "text/xml", String.Empty, null); } catch (WebException) { } Assert.AreEqual(HttpStatusCode.NotFound, request.CurrentWebResponse.StatusCode); ErrorData errorData = (ErrorData)StringUtils.DeserializeObject(request.GetLastResponseAsXML().OuterXml, typeof(ErrorData)); Assert.AreEqual(ErrorType.ForumOrThreadNotFound.ToString(), errorData.Code); Console.WriteLine("After GetForumSource_V1Xml_ReadOnly_Returns404"); }
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 CreateAs_NormalUser() { 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(); // give it some sort of psot so that it uses POST, also see if it is interested in the POST data // create the pick myRequest.SetCurrentUserNormal(); 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(); }
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 cPlusToApi(){ // Step 1. Try to create a comments forum using the API but as a normal user, should get unauthorised DnaTestURLRequest testUserReq = new DnaTestURLRequest(testUtils_CommentsAPI.sitename); testUserReq.SetCurrentUserNormal(); testUserReq = createForum(testUserReq, HttpStatusCode.Unauthorized); // will crash the test if it does not get the right status // Step 2. Use the Inspect User page (a C++ page) to update the user's groups setEdStatusCplus(testUserReq, true); Thread.Sleep(5000); // Step 3. Remove trace of this from the database, so that we can see that there is some caching somewhere clearFromDB(testUserReq); // Step 4. Try creating a comment forum again, should succeed because now the test user is an editor on the globally named site testUserReq = createForum(testUserReq, HttpStatusCode.OK); //// Step 5. Use the Inspect User page (a C++ page) to update the user's groups //setEdStatusCplus(testUserReq, false); ////Thread.Sleep(5000); //// Step 6. Remove trace of this from the database //clearFromDB(testUserReq); //// Step 7. try creating a comment forum again, shuould succeed because now the test user is an editor on the globally named site //testUserReq = createForum(testUserReq, HttpStatusCode.Unauthorized); // will crash the test if it does not get the right status }
public void EditPost_AsNormalUser_ReturnsError() { DnaTestURLRequest request = new DnaTestURLRequest(_siteName); request.SetCurrentUserNormal(); var xml = GetPost(request, @"editpost?skin=purexml&postid=" + _postId.ToString()); Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR")); Assert.IsNull(xml.SelectSingleNode("H2G2/POST-EDIT-FORM")); }
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 normalUser() { Console.WriteLine("Before userTypes - normalUser"); DnaTestURLRequest request = new DnaTestURLRequest(testUtils_ratingsAPI.sitename); request.SetCurrentUserNormal(); doIt_xml(request, HttpStatusCode.Unauthorized); Console.WriteLine("After userTypes - normalUser"); }
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 StartUp() { SnapshotInitialisation.RestoreFromSnapshot(); DnaTestURLRequest testUserReq = new DnaTestURLRequest(testUtils_CommentsAPI.sitename); testUserReq.SetCurrentUserNormal(); clearFromDB(testUserReq); using (FullInputContext inputContext = new FullInputContext("")) { inputContext.SendSignal("action=recache-groups"); } }
public void TestTypedArticleEditWithDateRange() { Console.WriteLine("Before TestTypedArticleEditWithDateRange"); TestTypedArticleCreateWithDateRangeUsingFreeTextDates(); DnaTestURLRequest request = new DnaTestURLRequest("actionnetwork"); request.SetCurrentUserNormal(); IInputContext inputContext = DnaMockery.CreateDatabaseInputContext(); using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader("")) { DateRangeInfo origDrInfo = new DateRangeInfo(); ReadTopDateRangeRecord(dataReader, ref origDrInfo); DateRangeInfo newDrInfo = new DateRangeInfo(); // Update without a time interval XmlDocument xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 16, 11, 1993, 17, 12, 2003, 0); ReadTopDateRangeRecord(dataReader, ref newDrInfo); Assert.IsTrue(newDrInfo.startDate.CompareTo(new DateTime(1993, 11, 16)) == 0, "StartDate incorrect"); Assert.IsTrue(newDrInfo.endDate.CompareTo(new DateTime(2003, 12, 18)) == 0, "EndDate incorrect"); Assert.IsTrue(newDrInfo.timeIntervalNull, "TimeInterval should be a null value"); Assert.IsTrue(GetEntryIDFromXml(xml) == newDrInfo.entryId, "Entry ID doesn't match"); Assert.IsTrue(newDrInfo.entryId == origDrInfo.entryId, "Entry ID should be same as original"); // Update with a time interval xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 17, 12, 1994, 18, 1, 2004, 27); ReadTopDateRangeRecord(dataReader, ref newDrInfo); Assert.IsTrue(newDrInfo.startDate.CompareTo(new DateTime(1994, 12, 17)) == 0, "StartDate incorrect"); Assert.IsTrue(newDrInfo.endDate.CompareTo(new DateTime(2004, 1, 19)) == 0, "EndDate incorrect"); Assert.IsFalse(newDrInfo.timeIntervalNull, "TimeInterval should not be a null value"); Assert.IsTrue(newDrInfo.timeInterval == 27, "TimeInterval should be 27"); Assert.IsTrue(GetEntryIDFromXml(xml) == newDrInfo.entryId, "Entry ID doesn't match"); Assert.IsTrue(newDrInfo.entryId == origDrInfo.entryId, "Entry ID should be same as original"); // Test error codes xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 30, 2, 1968, 5, 8, 1968, 10); Assert.IsTrue(ReadDateRangeErrorCode(xml) == "StartDateInvalid"); xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 6, 8, 1968, 31, 4, 1968, 10); Assert.IsTrue(ReadDateRangeErrorCode(xml) == "EndDateInvalid"); //xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 28, 2, 2068, 5, 8, 1968, 10); //Assert.IsTrue(ReadDateRangeErrorCode(xml) == "StartDateInTheFuture"); //xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 28, 2, 1968, 5, 8, 2068, 10); //Assert.IsTrue(ReadDateRangeErrorCode(xml) == "EndDateInTheFuture"); //xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 6, 8, 1968, 6, 8, 1968, 10); //Assert.IsTrue(ReadDateRangeErrorCode(xml) == "StartDateEqualsEndDate"); xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 6, 8, 1968, 5, 8, 1968, 10); Assert.IsTrue(ReadDateRangeErrorCode(xml) == "StartDateGreaterThanEndDate"); xml = UpdateTypedArticleWithDateRange(request, origDrInfo.entryId, 6, 8, 1968, 7, 8, 1968, 3); Assert.IsTrue(ReadDateRangeErrorCode(xml) == "TimeIntervalInvalid"); Console.WriteLine("After TestTypedArticleEditWithDateRange"); } }
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_GetKnownSiteWithNormalUser_ReturnsCorrectError() { var request = new DnaTestURLRequest(_siteName); request.SetCurrentUserNormal(); request.UseEditorAuthentication = true; request.RequestPage("sitemanager?skin=purexml"); var xmlDoc = request.GetLastResponseAsXML(); ValidateError(xmlDoc, "Authorization"); }
public void Test1UserComplaintPage() { DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); request.UseEditorAuthentication = false; request.RequestPage("UserComplaintPage?skin=purexml" + "&postid=" + Convert.ToString(_postId) ); XmlDocument doc = request.GetLastResponseAsXML(); //Check XML against Schema. DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2UserComplaintFlat.xsd"); validator.Validate(); }
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 MBAdmin_AsNormalUser_ReturnsForbidden() { var request = new DnaTestURLRequest(_siteName); request.SetCurrentUserNormal(); try { request.RequestPage("mbadmin"); } catch(Exception e) { Assert.IsTrue(e.Message.IndexOf("(401) Unauthorized") > 0); } }
public void BlogSummaryPageExists() { DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); string url = "BlogSummary?skin=purexml&dna_list_ns=1"; request.RequestPage(url); // Check to make sure that the page returned with the correct information XmlDocument xml = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri); validator.Validate(); }
public void TestMorePagesPage() { Console.WriteLine("Before MorePagesPage Tests - TestMorePagesPage"); DnaTestURLRequest request = new DnaTestURLRequest("h2g2"); request.SetCurrentUserNormal(); request.RequestPage(@"MA" + request.CurrentUserID.ToString() + "&skin=purexml"); // now get the response XmlDocument xml = request.GetLastResponseAsXML(); // Check to make sure that the page returned with the correct information Assert.IsTrue(xml.SelectSingleNode("/H2G2[@TYPE='MOREPAGES']") != null, "MorePages type does not exist!"); Console.WriteLine("After MorePagesPage Tests - TestMorePagesPage"); }
public void RemoveStickyThread_AsNormalUser_ReturnsError() { var siteName = "h2g2"; var request = new DnaTestURLRequest(siteName); request.SetCurrentUserNormal(); request.RequestPage("NF150?cmd=REMOVESTICKYTHREAD&stickythreadid=32&skin=purexml"); _forumPageTests.ValidateForumSchema(siteName, request); var doc = request.GetLastResponseAsXML(); Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR")); Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR/ERRORMESSAGE")); Assert.AreEqual("Viewing user unauthorised.", doc.SelectSingleNode("//H2G2/ERROR/ERRORMESSAGE").InnerText); }
public void GetForumThreadsXml_ReadOnly_ReturnsValidXml() { Console.WriteLine("Before GetForumXml_ReadOnly_ReturnsValidXml"); DnaTestURLRequest request = new DnaTestURLRequest(_sitename); request.SetCurrentUserNormal(); string url = String.Format("http://" + _server + "/dna/api/forums/ForumsService.svc/V1/site/{0}/forums/{1}/threads/{2}?format=xml", _sitename, 150, 33); // now get the response request.RequestPageWithFullURL(url, null, "text/xml"); // Check to make sure that the page returned with the correct information XmlDocument xml = request.GetLastResponseAsXML(); DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml.Replace("xmlns=\"http://schemas.datacontract.org/2004/07/BBC.Dna.Objects\"","") , _schemaForumThreads); validator.Validate(); Console.WriteLine("After GetForumXml_ReadOnly_ReturnsValidXml"); }
public void TestTypedArticleCreateCancelled() { Console.WriteLine("Before TestTypedArticleUpdateCancelled"); DnaTestURLRequest request = new DnaTestURLRequest("actionnetwork"); request.SetCurrentUserNormal(); IInputContext inputContext = DnaMockery.CreateDatabaseInputContext(); using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader("")) { // Create a "cancelled" typed article - i.e. do everything but actually create the article XmlDocument xml = CreateCancelledTypedArticle(request); Assert.IsTrue(GetMutiStageType(xml) == "TYPED-ARTICLE-CREATE"); Assert.IsTrue(IsMutiStageCancelled(xml)); Console.WriteLine("After TestTypedArticleCreateCancelled"); } }
public void TearDown() { if (_siteOptionList.GetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites") != _includeContentFromOtherSites) { using (FullInputContext inputcontext = new FullInputContext("")) { //Reset to initial value. _siteOptionList.SetValueBool(_siteId, "PersonalSpace", "IncludeContentFromOtherSites", _includeContentFromOtherSites, inputcontext.ReaderCreator, inputcontext.dnaDiagnostics); } //Recache Site Data. DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay"); request.SetCurrentUserNormal(); int id = request.CurrentUserID; request.RequestPage("U" + id.ToString() + "?_ns=1&skin=purexml"); } }
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 Test01_NonEditorError() { DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserNormal(); dnaRequest.UseEditorAuthentication = false; string relativePath = @"AllocateSubs?skin=purexml"; dnaRequest.RequestPage(relativePath); XmlDocument xmlResponse = dnaRequest.GetLastResponseAsXML(); //check for error tag XmlNode xmlError = xmlResponse.SelectSingleNode("/H2G2/ERROR"); Assert.IsTrue(xmlError != null, "No error returned for non-editor access"); Assert.IsTrue(xmlError.Attributes["TYPE"] != null, "No error type returned for non-editor access"); Assert.IsTrue(xmlError.Attributes["TYPE"].Value == "NOT-EDITOR", "Incorrect type returned for non-editor access"); xmlError = xmlResponse.SelectSingleNode("/H2G2/ERROR/ERRORMESSAGE"); Assert.IsTrue(xmlError != null && !String.IsNullOrEmpty(xmlError.InnerText), "No error message returned for non-editor access"); }