Пример #1
0
        public void BasicAuthLogin()
        {
            string content = DatabaseAutomation.DownloadPageAsAdmin("Missions");

            Console.WriteLine(content);
            Assert.IsFalse(Regex.IsMatch(content, "<input[^>]id=\\\"username\\\"", RegexOptions.IgnoreCase), "Shouldn't contain username login box");
        }
Пример #2
0
        public static string DownloadPageAsAdmin(string relativePath)
        {
            relativePath += relativePath.Contains("?") ? "&_auth=basic" : "?_auth=basic";

            WebClient client = new WebClient();

            client.Credentials = DatabaseAutomation.GetAdminCredential();
            return(client.DownloadString(new Uri(DatabaseAutomation.GetDatabaseUrl(), relativePath)));
        }
Пример #3
0
        public static string PostJsonAsAdmin(string relativePath, string post)
        {
            relativePath += relativePath.Contains("?") ? "&_auth=basic" : "?_auth=basic";

            WebClient client = new WebClient();

            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            client.Credentials = DatabaseAutomation.GetAdminCredential();
            return(client.UploadString(new Uri(DatabaseAutomation.GetDatabaseUrl(), relativePath), post));
        }
Пример #4
0
        public static Browser GetAdminBrowser()
        {
            Browser b    = GetBrowserAtUrl(new Uri(DatabaseAutomation.GetDatabaseUrl(), "Account/Login"));
            var     cred = DatabaseAutomation.GetAdminCredential();

            b.Find.ById <HtmlInputText>("username").Text     = cred.UserName;
            b.Find.ById <HtmlInputPassword>("password").Text = cred.Password;
            b.Find.ById <HtmlInputSubmit>("login").Click();
            return(b);
        }
Пример #5
0
        public void ErrorSendsEmail()
        {
            string[] olderFiles = Directory.GetFiles(DatabaseAutomation.GetMailDrop());
            try
            {
                DatabaseAutomation.DownloadPageAsAdmin("Admin/TestExceptionHandling");
            }
            catch (WebException ex)
            {
                Assert.AreEqual(WebExceptionStatus.ProtocolError, ex.Status, "Should get error from downloading page");
            }
            string[] newFiles = Directory.GetFiles(DatabaseAutomation.GetMailDrop());

            foreach (string file in newFiles.Except(olderFiles))
            {
                File.Delete(file);
            }

            Assert.AreEqual(olderFiles.Length + 1, newFiles.Length, "Should have sent one email based on error");
        }