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); } } }
public LicenseValidationScenario() { using (var dataContext = new DataContext()) { var country = DatabaseUtil.InsertItem(dataContext, dataContext.Countries, new Country() { CountryCode = "foo", CountryName = "country.name", NativeCountryName = "country.nativeCountryName" }); var vendorScenario = new WithAVendorDBScenario(); FeatureCode = vendorScenario.FeatureCode; PublicKeyXml = vendorScenario.PublicKeyXml; var customer = DatabaseUtil.InsertItem(dataContext, dataContext.Customers, new Customer() { Name = "customer.name", Street = "customer.street", PostalCode = "customer.postalCode", City = "customer.city", Region = "customer.region", CountryCode = country.CountryCode }); var customerApp = DatabaseUtil.InsertItem(dataContext, dataContext.CustomerApps, new CustomerApp() { ApplicationName = "test CustomerApp" }); var customerAppKey = DatabaseUtil.InsertItem(dataContext, dataContext.CustomerAppKeys, new CustomerAppKey() { CustomerAppId = customerApp.CustomerAppId }); AppKey = customerAppKey.AppKey; var license = DatabaseUtil.InsertItem(dataContext, dataContext.Licenses, new License() { OwnerName = "license.ownerName", LicenseExpires = DateTime.Now.AddDays(100), SkuId = vendorScenario.SkuId, PurchasingCustomerId = customer.ObjectId, OwningCustomerId = customer.ObjectId }); DatabaseUtil.InsertItem(dataContext, dataContext.LicenseCustomerApps, new LicenseCustomerApp() { CustomerAppId = customerApp.CustomerAppId, LicenseId = license.ObjectId }); } }
public LicenseValidationScenario() { using (var dataContext = new DataContext()) { var country = DatabaseUtil.InsertItem(dataContext, dataContext.Countries, new Country() { CountryCode = "foo", CountryName = "country.name", NativeCountryName = "country.nativeCountryName" }); var vendorScenario = new WithAVendorDBScenario(); FeatureCode = vendorScenario.FeatureCode; PublicKeyXml = vendorScenario.PublicKeyXml; var customer = DatabaseUtil.InsertItem(dataContext, dataContext.Customers, new Customer() { Name = "customer.name", Street = "customer.street", PostalCode = "customer.postalCode", City = "customer.city", Region = "customer.region", CountryCode = country.CountryCode }); var customerApp = DatabaseUtil.InsertItem(dataContext, dataContext.CustomerApps, new CustomerApp() { ApplicationName = "test CustomerApp" }); var customerAppKey = DatabaseUtil.InsertItem(dataContext, dataContext.CustomerAppKeys, new CustomerAppKey() { CustomerAppId = customerApp.CustomerAppId }); AppKey = customerAppKey.AppKey; var license = DatabaseUtil.InsertItem(dataContext, dataContext.Licenses, new License() { OwnerName = "license.ownerName", LicenseExpires = DateTime.Now.AddDays(100), SkuId = vendorScenario.SkuId, PurchasingCustomerId = customer.ObjectId, OwningCustomerId = customer.ObjectId }); DatabaseUtil.InsertItem(dataContext, dataContext.LicenseCustomerApps, new LicenseCustomerApp() { CustomerAppId = customerApp.CustomerAppId, LicenseId = license.ObjectId }); } }
public void CanUseALicensePurchasedViaEJunkie() { var vendorScenario = new WithAVendorDBScenario(); var payerEmail = "*****@*****.**"; var customerEmail = "*****@*****.**"; var customerPassword = "******"; var smtpServer = SimpleSmtpServer.Start(25); try { using (var site = new KeyHubWebDriver()) { using (var client = new WebClient()) { var uploadVariables = new NameValueCollection(); uploadVariables.Add("handshake", vendorScenario.VendorCredential); uploadVariables.Add("txn_id", GetRandomString()); uploadVariables.Add("payment_status", "Completed"); uploadVariables.Add("payment_date", "02:51:26 Jul 18, 2012 MST"); uploadVariables.Add("num_cart_items", "0"); uploadVariables.Add("payer_name", "payerName"); uploadVariables.Add("payer_email", payerEmail); uploadVariables.Add("num_cart_items", "1"); uploadVariables.Add("item_name1", "item name"); uploadVariables.Add("item_number1", vendorScenario.SkuCode); uploadVariables.Add("mc_gross_1", "350"); uploadVariables.Add("quantity1", "1"); client.UploadValues(site.UrlFor("Api/TransactionByIpn/" + vendorScenario.VendorId), uploadVariables); } var email = smtpServer.ReceivedEmail.Single(); Assert.Equal(payerEmail, email.ToAddresses.Single().Address); var emailBody = Encoding.ASCII.GetString(Convert.FromBase64String(email.MessageParts.Single().BodyData)); var emailLinkMatch = Regex.Match(emailBody, @"\s(http[^\s]+)\s", RegexOptions.Multiline | RegexOptions.IgnoreCase); Assert.True(emailLinkMatch.Success, "Did not find followup link in email body: " + emailBody); var emailLink = emailLinkMatch.Groups[1].Value; using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(emailLink); browser.FindElementByCssSelector("a[href^='/Transaction/Checkout']").Click(); browser.FindElementByCssSelector("a[href^='/Account/Register']").Click(); SiteUtil.SubmitRegistrationForm(browser, customerEmail, customerPassword); SiteUtil.WaitUntilUserIsLoggedIn(browser); SubmitTransactionCheckoutFormWithNewCustomer(browser); var appKeyValue = GetAppKeyFromTransactionCompletePage(browser); LicenseValidatorTests.AssertRemoteValidationCheckPasses( site, "example.com", appKeyValue, vendorScenario.FeatureCode, vendorScenario.PublicKeyXml); } } } finally { smtpServer.Stop(); } }
public void CanUseALicensePurchasedViaEJunkie() { var vendorScenario = new WithAVendorDBScenario(); var payerEmail = "*****@*****.**"; var customerEmail = "*****@*****.**"; var customerPassword = "******"; var smtpServer = SimpleSmtpServer.Start(25); try { using (var site = new KeyHubWebDriver()) { using (var client = new WebClient()) { var uploadVariables = new NameValueCollection(); uploadVariables.Add("handshake", vendorScenario.VendorCredential); uploadVariables.Add("txn_id", GetRandomString()); uploadVariables.Add("payment_status", "Completed"); uploadVariables.Add("payment_date", "02:51:26 Jul 18, 2012 MST"); uploadVariables.Add("num_cart_items", "0"); uploadVariables.Add("payer_name", "payerName"); uploadVariables.Add("payer_email", payerEmail); uploadVariables.Add("num_cart_items", "1"); uploadVariables.Add("item_name1", "item name"); uploadVariables.Add("item_number1", vendorScenario.SkuCode); uploadVariables.Add("mc_gross_1", "350"); uploadVariables.Add("quantity1", "1"); client.UploadValues(site.UrlFor("Api/TransactionByIpn/" + vendorScenario.VendorId), uploadVariables); } var email = smtpServer.ReceivedEmail.Single(); Assert.Equal(payerEmail, email.ToAddresses.Single().Address); var emailBody = Encoding.ASCII.GetString(Convert.FromBase64String(email.MessageParts.Single().BodyData)); var emailLinkMatch = Regex.Match(emailBody, @"\s(http[^\s]+)\s", RegexOptions.Multiline | RegexOptions.IgnoreCase); Assert.True(emailLinkMatch.Success, "Did not find followup link in email body: " + emailBody); var emailLink = emailLinkMatch.Groups[1].Value; using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(emailLink); browser.FindElementByCssSelector("a[href^='/Transaction/Checkout']").Click(); browser.FindElementByCssSelector("a[href^='/Account/Register']").Click(); SiteUtil.SubmitRegistrationForm(browser, customerEmail, customerPassword); SiteUtil.WaitUntilUserIsLoggedIn(browser); SubmitTransactionCheckoutFormWithNewCustomer(browser); var appKeyValue = GetAppKeyFromTransactionCompletePage(browser); LicenseValidatorTests.AssertRemoteValidationCheckPasses( site, "example.com", appKeyValue, vendorScenario.FeatureCode, vendorScenario.PublicKeyXml); } } } finally { smtpServer.Stop(); } }
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); } } }