Esempio n. 1
0
        public void CanLoginLocallyAfterChangingPassword()
        {
            var email          = "*****@*****.**";
            var firstPassword  = "******";
            var secondPassword = "******";

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, email, firstPassword);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, email, firstPassword);
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href^='/Account']").Click();
                    browser.FindElementByCssSelector("a[href^='/Account/ChangePassword']").Click();

                    browser.FindElementByCssSelector("#OldPassword").SendKeys(firstPassword);
                    browser.FindElementByCssSelector("#NewPassword").SendKeys(secondPassword);
                    browser.FindElementByCssSelector("#ConfirmPassword").SendKeys(secondPassword);
                    browser.FindElementByCssSelector("input[type='submit']").Click();

                    // Ensure the change saves by waiting for the browser to return to the account edit page
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']");
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, email, secondPassword);
                }
            }
        }
Esempio n. 2
0
        public void CanLoginLocallyAfterChangingEmail()
        {
            var firstEmail  = "*****@*****.**";
            var secondEmail = "*****@*****.**";
            var password    = "******";

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, firstEmail, password);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, firstEmail, password);

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href^='/Account']").Click();
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']").Click();

                    var emailForm = browser.FindElementByCssSelector("#Email");
                    emailForm.Clear();
                    emailForm.SendKeys(secondEmail);
                    browser.FindElementByCssSelector("input[value='Save']").Click();

                    // Ensure the change saves by waiting for the browser to return to the account edit page
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']");
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, secondEmail.ToUpper(), password);
                }
            }
        }
Esempio n. 3
0
        private static void VendorManuallyCreatesTransaction(Action <RemoteWebDriver> vendorActionBeforeCreatingTransaction, Action <RemoteWebDriver> transactionSubmitHandler)
        {
            var vendorScenario = new WithAVendorDBScenario();
            var vendorEmail    = "*****@*****.**";
            var vendorPassword = "******";

            using (var site = new KeyHubWebDriver())
            {
                string editVendorUserUrl = null;

                SiteUtil.CreateLocalAccount(site, vendorEmail, vendorPassword, firstBrowser =>
                {
                    firstBrowser.FindElementByCssSelector("a[href='/Account/LogOff']");
                    firstBrowser.Navigate().GoToUrl(site.UrlFor("/Account"));

                    editVendorUserUrl =
                        firstBrowser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href");
                });

                //  Log in as admin to give the new vendor account vendor permissions
                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor(editVendorUserUrl));

                    SiteUtil.SubmitLoginForm(browser, "admin", "password");

                    AdminUtil.CreateAccountRightsFor(browser, vendorEmail, ObjectTypes.Vendor, vendorScenario.VendorName);
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, vendorEmail, vendorPassword);

                    vendorActionBeforeCreatingTransaction(browser);

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href='/Transaction/Create']").Click();

                    SiteUtil.SetValueForChosenJQueryControlMulti(browser, "div#Transaction_SelectedSKUGuids_chzn",
                                                                 vendorScenario.SkuCode);

                    browser.FindElementByCssSelector("form[action^='/Transaction/Create'] input[type='submit']").Click();

                    transactionSubmitHandler(browser);

                    var appKeyValue = GetAppKeyFromTransactionCompletePage(browser);

                    LicenseValidatorTests.AssertRemoteValidationCheckPasses(
                        site, "example.com",
                        appKeyValue,
                        vendorScenario.FeatureCode,
                        vendorScenario.PublicKeyXml);
                }
            }
        }
Esempio n. 4
0
        public void ShouldGiveWarningMessageWhenUserRegistersEmailAlreadyInUse()
        {
            var email    = ConfigurationManager.AppSettings.Get("googleTestEmail");
            var password = ConfigurationManager.AppSettings.Get("googleTestPassword");

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, email, password);
                SiteUtil.CreateLocalAccount(site, email, password, browser =>
                {
                    var errorText = browser.FindElementByCssSelector(".validation-summary-errors li").Text;
                    Assert.Contains("The email address registered is already in use", errorText);
                });
            }
        }
Esempio n. 5
0
        public void CanRegisterLocallyThenAssociateAndDisassociate3rdPartyLogin()
        {
            var email    = ConfigurationManager.AppSettings.Get("googleTestEmail");
            var password = ConfigurationManager.AppSettings.Get("googleTestPassword");

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, email, password);

                int expectedUserID;

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

                    browser.Navigate().GoToUrl(site.UrlFor("/Account/Login"));
                    browser.FindElementByCssSelector("input[name=provider][value=Google]").Click();

                    FillGoogleLoginForm(browser, email, password);

                    var errorText = browser.FindElementByCssSelector(".error").Text;
                    Assert.Contains("The email address used to login is already in use", errorText);

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, email, password);

                    expectedUserID = GetCurrentUserId(browser);

                    browser.FindElementByCssSelector("a[href='/Account']").Click();
                    browser.FindElementByCssSelector("a[href='/Account/LinkAccount']").Click();

                    browser.Navigate().GoToUrl(site.UrlFor("/Account/LinkAccount"));
                    Console.WriteLine("Page is " + browser.Url);
                    browser.FindElementByCssSelector("input[name=provider][value=Google]").Click();

                    var successText = browser.FindElementByCssSelector(".success").Text;
                    Assert.Contains("Your google login has been linked", successText);
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("input[type='submit'][value='Google']").Click();
                    FillGoogleLoginForm(browser, email, password);
                    SiteUtil.WaitUntilUserIsLoggedIn(browser);

                    Assert.Equal(expectedUserID, GetCurrentUserId(browser));

                    browser.FindElementByCssSelector("a[href='/Account']").Click();
                    browser.FindElementByCssSelector("a[href='/Account/LinkAccount']").Click();
                    browser.FindElementByCssSelector("a[href^='/Account/UnlinkLogin']").Click();
                    browser.FindElementByCssSelector("form[action^='/Account/UnlinkLogin'] input[type='submit']").Click();

                    var successText = browser.FindElementByCssSelector(".success").Text;
                    Assert.Contains("Your Google login has been unlinked", successText);
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("input[type='submit'][value='Google']").Click();
                    FillGoogleLoginForm(browser, email, password);
                    var errorText = browser.FindElementByCssSelector(".error").Text;
                    Assert.Contains("The email address used to login is already in use", errorText);
                }
            }
        }