Пример #1
0
        protected UserInfo CreateUserWithVerifiedEmailAddress(string email, string password)
        {
            SnCore.WebServices.WebAccountService.WebAccountService endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();

            UserInfo result = new UserInfo();
            result.email = email;
            result.password = password;

            result.id = CreateUser(email, password);
            Assert.IsTrue(result.id > 0);

            result.ticket = Login(email, password);
            Assert.IsNotEmpty(result.ticket);

            Assert.IsFalse(endpoint.HasVerifiedEmail(result.ticket, result.id));
            SnCore.WebServices.WebAccountService.TransitAccountEmailConfirmation[] confirmations = endpoint.GetAccountEmailConfirmations(
                GetAdminTicket(), result.id, null);

            string verifiedemail = endpoint.VerifyAccountEmail(
                confirmations[0].Id, confirmations[0].Code);

            Console.WriteLine("Verified: {0}", verifiedemail);
            Assert.AreEqual(verifiedemail, result.email);
            Assert.IsTrue(endpoint.HasVerifiedEmail(result.ticket, result.id));

            return result;
        }
Пример #2
0
 protected int CreateUser(string email, string password, DateTime dateofbirth)
 {
     SnCore.WebServices.WebAccountService.TransitAccount t_instance = new SnCore.WebServices.WebAccountService.TransitAccount();
     t_instance.Name = GetNewString();
     t_instance.Password = password;
     t_instance.Birthday = dateofbirth;
     SnCore.WebServices.WebAccountService.WebAccountService account_endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();
     int id = account_endpoint.CreateAccount(string.Empty, email, t_instance);
     Console.WriteLine("Created user: {0}", id);
     Assert.IsTrue(id > 0);
     return id;
 }
Пример #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));
        }
Пример #4
0
 public void TestLogin()
 {
     WebAccountService service = new WebAccountService();
     string ticket = service.Login("*****@*****.**", "password");
     Assert.IsFalse(string.IsNullOrEmpty(ticket));
 }
Пример #5
0
 public string GetAdminTicket()
 {
     SnCore.WebServices.WebAccountService.WebAccountService endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();
     return endpoint.Login("*****@*****.**", "password");
 }
Пример #6
0
 public SnCore.WebServices.WebAccountService.TransitAccount GetAdminAccount()
 {
     SnCore.WebServices.WebAccountService.WebAccountService endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();
     return endpoint.GetAccount(GetAdminTicket(), true);
 }
Пример #7
0
 public string Login(string email, string password)
 {
     SnCore.WebServices.WebAccountService.WebAccountService endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();
     return endpoint.Login(email, password);
 }
Пример #8
0
 protected void DeleteUser(int id)
 {
     SnCore.WebServices.WebAccountService.WebAccountService account_endpoint = new SnCore.WebServices.WebAccountService.WebAccountService();
     account_endpoint.DeleteAccount(GetAdminTicket(), id);
 }
Пример #9
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);
            }
        }