Пример #1
0
        public void TestLogin()
        {
            WebAccountService service = new WebAccountService();
            string            ticket  = service.Login("*****@*****.**", "password");

            Assert.IsFalse(string.IsNullOrEmpty(ticket));
        }
Пример #2
0
        public void TestExtractUrls()
        {
            WebAccountService service = new WebAccountService();
            string            ticket  = service.Login("*****@*****.**", "password");
            Cookie            cookie  = new Cookie(WebAccountTests.sSnCoreAuthCookieName, ticket, "/", "localhost");

            Uri root = new Uri("http://localhost/SnCoreWeb/");
            Uri uri  = new Uri("http://localhost/SnCoreWeb/DiscussionThreadView.aspx?id=86&did=42&ReturnUrl=%2fSnCoreWeb%2fDiscussionTopOfThreadsView.aspx");

            List <Uri> links = new List <Uri>();
            double     ts    = 0;

            TestPage(root, uri, cookie, out links, out ts);

            Console.WriteLine("{0} links", links.Count);

            foreach (Uri link in links)
            {
                Console.WriteLine("[{0}]", link);
                Assert.IsTrue(link.Query.IndexOf("/") < 0);
            }
        }
Пример #3
0
        public void TestHttpFetchWithLogin()
        {
            WebAccountService service = new WebAccountService();
            string            ticket  = service.Login("*****@*****.**", "password");
            Cookie            cookie  = new Cookie(sSnCoreAuthCookieName, ticket, "/", "localhost");

            CookieContainer cookies = new CookieContainer();

            cookies.Add(cookie);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost/SnCoreWeb/AccountPreferencesManage.aspx");

            request.CookieContainer   = cookies;
            request.Method            = "GET";
            request.AllowAutoRedirect = false;

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream          s        = response.GetResponseStream();
            StreamReader    sr       = new StreamReader(s);
            string          data     = sr.ReadToEnd();

            Assert.IsTrue(response.StatusCode == HttpStatusCode.OK, string.Format("Response code was {0}", response.StatusCode));
            Assert.IsFalse(string.IsNullOrEmpty(data));
        }