本文整理汇总了C#中Tests.DnaTestURLRequest.SetCurrentUserSuperUser方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.SetCurrentUserSuperUser方法的具体用法?C# DnaTestURLRequest.SetCurrentUserSuperUser怎么用?C# DnaTestURLRequest.SetCurrentUserSuperUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.SetCurrentUserSuperUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeUserEditorOfSite
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);
}
示例2: TermsFilterAdminPage_UpdateExistingTerm_CorrectlyUpdates
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);
}
示例3: TermsFilterAdminPage_AsSuperUser_PassesValidation
public void TermsFilterAdminPage_AsSuperUser_PassesValidation()
{
var request = new DnaTestURLRequest(SiteName) {UseEditorAuthentication = true};
request.SetCurrentUserSuperUser();
request.RequestPage("termsfilteradmin?modclassid=2&skin=purexml");
ValidateResponse(request);
}
示例4: TermsFilterImportPage_WithoutEditorAuthenticationAsInSecured_AccessDenied
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);
}
示例5: SetSiteOptionForAnonymousPosting
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);
}
示例6: superUser
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");
}
示例7: SiteManager_GetKnownSite_ReturnsCorrectXML
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);
}
示例8: TestModeratorManagementPageXml
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();
}
示例9: TermsFilterAdminPage_WithoutEditorAuthentication_AccessDenied
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);
}
示例10: TermsFilterImportPage_WithoutEditorAuthenticationAsSecure_NoError
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);
}
示例11: GivenIamASuperUser_WhenICreateATwitterProfileWithValidData_ThenMyProfileIsCreatedSuccessfully
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));
}
示例12: GivenIamASuperUser_WhenICreateATwitterProfile_WithABlankTitle_ThenIamShownTheMissingTitleErrorMessage
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);
}
示例13: CallAPIRequest
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;
}
示例14: UserList_RemovePostsE2EWithMBs_ReturnsCorrectResults
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);
}
}
}
示例15: UserList_SetMultipleBanned_ReturnsCorrectResults
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"));
}
}