当前位置: 首页>>代码示例>>C#>>正文


C# DnaTestURLRequest.SetCurrentUserNormal方法代码示例

本文整理汇总了C#中Tests.DnaTestURLRequest.SetCurrentUserNormal方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.SetCurrentUserNormal方法的具体用法?C# DnaTestURLRequest.SetCurrentUserNormal怎么用?C# DnaTestURLRequest.SetCurrentUserNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tests.DnaTestURLRequest的用法示例。


在下文中一共展示了DnaTestURLRequest.SetCurrentUserNormal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAs_NormalUser

        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();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:30,代码来源:editorsPicksTests_v1.cs

示例2: Test1CreateForumWithNoCloseDate

        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");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:CommentForumClosingDateTests.cs

示例3: countForums

        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;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:32,代码来源:TestUtils_commentsAPI.cs

示例4: GetForumSource_V1Xml_ReadOnly_Returns404

        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");

        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:forumSource.cs

示例5: 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);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:27,代码来源:ModeratorManagementPageTests.cs

示例6: CreateAs_NormalUser

        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();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:editorsPicksTests_v1.cs

示例7: Setup

        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));
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:UserPageTests.cs

示例8: cPlusToApi

        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


        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:32,代码来源:groupSignalTests.cs

示例9: EditPost_AsNormalUser_ReturnsError

 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"));
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:8,代码来源:EditPostsPageTests.cs

示例10: TestModeratorManagementPageNonSuperuser

        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"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:10,代码来源:ModeratorManagementPageTests.cs

示例11: TestModeratePostsPageNonModerator

        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"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:10,代码来源:ModeratePostsPageTests.cs

示例12: TestReturnKeyPhrasesInCategoryList

 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");
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:11,代码来源:CategoryTests.cs

示例13: normalUser

        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");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:11,代码来源:userTypeTest_v1.cs

示例14: UserList_AsNormalUser_ReturnsUnauthorised

        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");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:11,代码来源:UserListPageTest.cs

示例15: HostDashboardUserActivity_AsNormalUser_ReturnsUnauthorised

        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");
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:11,代码来源:HostDashboarduseractivityPageTest.cs


注:本文中的Tests.DnaTestURLRequest.SetCurrentUserNormal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。