예제 #1
0
        public async Task CanCreateRefunds()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Server.ActivateLTC();
                await s.StartAsync();

                var user = s.Server.NewAccount();
                await user.GrantAccessAsync();

                s.GoToLogin();
                s.Login(user.RegisterDetails.Email, user.RegisterDetails.Password);
                user.RegisterDerivationScheme("BTC");
                await s.Server.ExplorerNode.GenerateAsync(1);

                foreach (var multiCurrency in new[] { false, true })
                {
                    if (multiCurrency)
                    {
                        user.RegisterDerivationScheme("LTC");
                    }
                    foreach (var rateSelection in new[] { "FiatText", "CurrentRateText", "RateThenText" })
                    {
                        await CanCreateRefundsCore(s, user, multiCurrency, rateSelection);
                    }
                }
            }
        }
예제 #2
0
        public async Task CanUseLanguageDropdown()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme("BTC");

                var invoiceId = s.CreateInvoice(store.storeName);
                s.GoToInvoiceCheckout(invoiceId);
                Assert.True(s.Driver.FindElement(By.Id("DefaultLang")).FindElements(By.TagName("option")).Count > 1);
                var payWithTextEnglish = s.Driver.FindElement(By.Id("pay-with-text")).Text;

                var prettyDropdown = s.Driver.FindElement(By.Id("prettydropdown-DefaultLang"));
                prettyDropdown.Click();
                await Task.Delay(200);

                prettyDropdown.FindElement(By.CssSelector("[data-value=\"da-DK\"]")).Click();
                await Task.Delay(1000);

                Assert.NotEqual(payWithTextEnglish, s.Driver.FindElement(By.Id("pay-with-text")).Text);
                s.Driver.Navigate().GoToUrl(s.Driver.Url + "?lang=da-DK");

                Assert.NotEqual(payWithTextEnglish, s.Driver.FindElement(By.Id("pay-with-text")).Text);

                s.Driver.Quit();
            }
        }
예제 #3
0
        public async Task CanCreateStores()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                var alice = s.RegisterNewUser();
                var store = s.CreateNewStore().storeName;
                s.AddDerivationScheme();
                s.Driver.AssertNoError();
                Assert.Contains(store, s.Driver.PageSource);
                var storeUrl = s.Driver.Url;
                s.ClickOnAllSideMenus();
                s.GoToInvoices();
                s.CreateInvoice(store);
                s.AssertHappyMessage();
                s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
                var invoiceUrl = s.Driver.Url;

                // When logout we should not be able to access store and invoice details
                s.Driver.FindElement(By.Id("Logout")).Click();
                s.Driver.Navigate().GoToUrl(storeUrl);
                Assert.Contains("ReturnUrl", s.Driver.Url);
                s.Driver.Navigate().GoToUrl(invoiceUrl);
                Assert.Contains("ReturnUrl", s.Driver.Url);
                s.GoToRegister();
                // When logged we should not be able to access store and invoice details
                var bob = s.RegisterNewUser();
                s.Driver.Navigate().GoToUrl(storeUrl);
                Assert.Contains("ReturnUrl", s.Driver.Url);
                s.Driver.Navigate().GoToUrl(invoiceUrl);
                s.AssertNotFound();
                s.GoToHome();
                s.Logout();

                // Let's add Bob as a guest to alice's store
                LogIn(s, alice);
                s.Driver.Navigate().GoToUrl(storeUrl + "/users");
                s.Driver.FindElement(By.Id("Email")).SendKeys(bob + Keys.Enter);
                Assert.Contains("User added successfully", s.Driver.PageSource);
                s.Logout();

                // Bob should not have access to store, but should have access to invoice
                LogIn(s, bob);
                s.Driver.Navigate().GoToUrl(storeUrl);
                Assert.Contains("ReturnUrl", s.Driver.Url);
                s.Driver.Navigate().GoToUrl(invoiceUrl);
                s.Driver.AssertNoError();

                // Alice should be able to delete the store
                s.Logout();
                LogIn(s, alice);
                s.Driver.FindElement(By.Id("Stores")).Click();
                s.Driver.FindElement(By.LinkText("Remove")).Click();
                s.Driver.FindElement(By.Id("continue")).Click();
                s.Driver.FindElement(By.Id("Stores")).Click();
                s.Driver.Navigate().GoToUrl(storeUrl);
                Assert.Contains("ReturnUrl", s.Driver.Url);
            }
        }
예제 #4
0
        public async Task CanCreateAppPoS()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.RegisterNewUser();
                var store = s.CreateNewStore();

                s.Driver.FindElement(By.Id("Apps")).Click();
                s.Driver.FindElement(By.Id("CreateNewApp")).Click();
                s.Driver.FindElement(By.Name("Name")).SendKeys("PoS" + Guid.NewGuid());
                s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("PointOfSale" + Keys.Enter);
                s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(store + Keys.Enter);
                s.Driver.FindElement(By.Id("Create")).Click();
                s.Driver.FindElement(By.Id("DefaultView")).SendKeys("Cart" + Keys.Enter);
                s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
                s.Driver.FindElement(By.Id("ViewApp")).ForceClick();

                var posBaseUrl = s.Driver.Url.Replace("/Cart", "");
                Assert.True(s.Driver.PageSource.Contains("Tea shop"), "Unable to create PoS");
                Assert.True(s.Driver.PageSource.Contains("Cart"), "PoS not showing correct default view");

                s.Driver.Url = posBaseUrl + "/static";
                Assert.False(s.Driver.PageSource.Contains("Cart"), "Static PoS not showing correct view");

                s.Driver.Url = posBaseUrl + "/cart";
                Assert.True(s.Driver.PageSource.Contains("Cart"), "Cart PoS not showing correct view");

                s.Driver.Quit();
            }
        }
예제 #5
0
        public async Task CanHandleRefundEmailForm()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme("BTC");

                var emailAlreadyThereInvoiceId = s.CreateInvoice(store.storeName, 100, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(emailAlreadyThereInvoiceId);
                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
                s.GoToHome();
                var invoiceId = s.CreateInvoice(store.storeName);
                s.GoToInvoiceCheckout(invoiceId);
                Assert.True(s.Driver.FindElement(By.Id("emailAddressFormInput")).Displayed);
                s.Driver.FindElement(By.Id("emailAddressFormInput")).SendKeys("xxx");
                s.Driver.FindElement(By.Id("emailAddressForm")).FindElement(By.CssSelector("button.action-button"))
                .Click();

                Assert.True(s.Driver.FindElement(By.Id("emailAddressFormInput")).Displayed);
                s.Driver.FindElement(By.Id("emailAddressFormInput")).SendKeys("@g.com");
                s.Driver.FindElement(By.Id("emailAddressForm")).FindElement(By.CssSelector("button.action-button"))
                .Click();

                await Task.Delay(1000);

                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));

                s.Driver.Navigate().Refresh();

                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
            }
        }
예제 #6
0
        public async Task CanCreateAppCF()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("Apps")).Click();
                s.Driver.FindElement(By.Id("CreateNewApp")).Click();
                s.Driver.FindElement(By.Name("Name")).SendKeys("CF" + Guid.NewGuid());
                s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("Crowdfund" + Keys.Enter);
                s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(store + Keys.Enter);
                s.Driver.FindElement(By.Id("Create")).Click();
                s.Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
                s.Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
                s.Driver.FindElement(By.Id("TargetCurrency")).SendKeys("JPY");
                s.Driver.FindElement(By.Id("TargetAmount")).SendKeys("700");
                s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
                s.Driver.FindElement(By.Id("ViewApp")).ForceClick();
                s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
                Assert.True(s.Driver.PageSource.Contains("Currently Active!"), "Unable to create CF");
                s.Driver.Quit();
            }
        }
예제 #7
0
        public async Task CanUseLndSeedBackup()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Server.ActivateLightning();
                await s.StartAsync();

                s.RegisterNewUser(true);
                s.Driver.FindElement(By.Id("ServerSettings")).Click();
                s.Driver.AssertNoError();
                s.Driver.FindElement(By.LinkText("Services")).Click();

                Logs.Tester.LogInformation("Let's if we can access LND's seed");
                Assert.Contains("server/services/lndseedbackup/BTC", s.Driver.PageSource);
                s.Driver.Navigate().GoToUrl(s.Link("/server/services/lndseedbackup/BTC"));
                s.Driver.FindElement(By.Id("details")).Click();
                var seedEl = s.Driver.FindElement(By.Id("SeedTextArea"));
                Assert.True(seedEl.Displayed);
                Assert.Contains("about over million", seedEl.Text, StringComparison.OrdinalIgnoreCase);
                var passEl = s.Driver.FindElement(By.Id("PasswordInput"));
                Assert.True(passEl.Displayed);
                Assert.Contains(passEl.Text, "hellorockstar", StringComparison.OrdinalIgnoreCase);
                s.Driver.FindElement(By.Id("delete")).Click();
                s.Driver.FindElement(By.Id("continue")).Click();
                s.AssertHappyMessage();
                seedEl = s.Driver.FindElement(By.Id("SeedTextArea"));
                Assert.Contains("Seed removed", seedEl.Text, StringComparison.OrdinalIgnoreCase);
            }
        }
예제 #8
0
        public void CanManageWallet()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                s.CreateNewStore();

                // In this test, we try to spend from a manual seed. We import the xpub 49'/0'/0', then try to use the seed
                // to sign the transaction
                var mnemonic = "usage fever hen zero slide mammal silent heavy donate budget pulse say brain thank sausage brand craft about save attract muffin advance illegal cabbage";
                var root     = new Mnemonic(mnemonic).DeriveExtKey();
                s.AddDerivationScheme("ypub6WWc2gWwHbdnAAyJDnR4SPL1phRh7REqrPBfZeizaQ1EmTshieRXJC3Z5YoU4wkcdKHEjQGkh6AYEzCQC1Kz3DNaWSwdc1pc8416hAjzqyD");
                var tx = s.Server.ExplorerNode.SendToAddress(BitcoinAddress.Create("bcrt1qmxg8fgnmkp354vhe78j6sr4ut64tyz2xyejel4", Network.RegTest), Money.Coins(3.0m));
                s.Server.ExplorerNode.Generate(1);

                s.Driver.FindElement(By.Id("Wallets")).Click();
                s.Driver.FindElement(By.LinkText("Manage")).Click();

                s.ClickOnAllSideMenus();

                // We setup the fingerprint and the account key path
                s.Driver.FindElement(By.Id("WalletSettings")).ForceClick();
                s.Driver.FindElement(By.Id("AccountKeys_0__MasterFingerprint")).SendKeys("8bafd160");
                s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).SendKeys("m/49'/0'/0'" + Keys.Enter);

                // Check the tx sent earlier arrived
                s.Driver.FindElement(By.Id("WalletTransactions")).ForceClick();
                var walletTransactionLink = s.Driver.Url;
                Assert.Contains(tx.ToString(), s.Driver.PageSource);


                void SignWith(string signingSource)
                {
                    // Send to bob
                    s.Driver.FindElement(By.Id("WalletSend")).Click();
                    var bob = new Key().PubKey.Hash.GetAddress(Network.RegTest);

                    s.Driver.FindElement(By.Id("Destination")).SendKeys(bob.ToString());
                    s.Driver.FindElement(By.Id("Amount")).SendKeys("1");
                    s.Driver.ScrollTo(By.Id("SendMenu"));
                    s.Driver.FindElement(By.Id("SendMenu")).ForceClick();
                    s.Driver.FindElement(By.CssSelector("button[value=seed]")).Click();

                    // Input the seed
                    s.Driver.FindElement(By.Id("SeedOrKey")).SendKeys(signingSource + Keys.Enter);

                    // Broadcast
                    Assert.Contains(bob.ToString(), s.Driver.PageSource);
                    Assert.Contains("1.00000000", s.Driver.PageSource);
                    s.Driver.FindElement(By.CssSelector("button[value=broadcast]")).Click();
                    Assert.Equal(walletTransactionLink, s.Driver.Url);
                }

                SignWith(mnemonic);
                var accountKey = root.Derive(new KeyPath("m/49'/0'/0'")).GetWif(Network.RegTest).ToString();
                SignWith(accountKey);
            }
        }
예제 #9
0
 public void CanNavigateServerSettings()
 {
     using (var s = SeleniumTester.Create())
     {
         s.Start();
         s.RegisterNewUser(true);
         s.Driver.FindElement(By.Id("ServerSettings")).Click();
         s.Driver.AssertNoError();
         s.ClickOnAllSideMenus();
         s.Driver.Quit();
     }
 }
예제 #10
0
        public async Task CanUsePairing()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.Driver.Navigate().GoToUrl(s.Link("/api-access-request"));
                Assert.Contains("ReturnUrl", s.Driver.Url);
                s.GoToRegister();
                var alice = s.RegisterNewUser();
                var store = s.CreateNewStore().storeName;
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("Tokens")).Click();
                s.Driver.FindElement(By.Id("CreateNewToken")).Click();
                s.Driver.FindElement(By.Id("RequestPairing")).Click();
                string pairingCode = AssertUrlHasPairingCode(s);

                s.Driver.FindElement(By.Id("ApprovePairing")).Click();
                s.AssertHappyMessage();
                Assert.Contains(pairingCode, s.Driver.PageSource);

                var client = new NBitpayClient.Bitpay(new Key(), s.Server.PayTester.ServerUri);
                await client.AuthorizeClient(new NBitpayClient.PairingCode(pairingCode));

                await client.CreateInvoiceAsync(new NBitpayClient.Invoice()
                {
                    Price             = 0.000000012m,
                    Currency          = "USD",
                    FullNotifications = true
                }, NBitpayClient.Facade.Merchant);

                client = new NBitpayClient.Bitpay(new Key(), s.Server.PayTester.ServerUri);

                var code = await client.RequestClientAuthorizationAsync("hehe", NBitpayClient.Facade.Merchant);

                s.Driver.Navigate().GoToUrl(code.CreateLink(s.Server.PayTester.ServerUri));
                s.Driver.FindElement(By.Id("ApprovePairing")).Click();

                await client.CreateInvoiceAsync(new NBitpayClient.Invoice()
                {
                    Price             = 0.000000012m,
                    Currency          = "USD",
                    FullNotifications = true
                }, NBitpayClient.Facade.Merchant);

                s.Driver.Navigate().GoToUrl(s.Link("/api-tokens"));
                s.Driver.FindElement(By.Id("RequestPairing")).Click();
                s.Driver.FindElement(By.Id("ApprovePairing")).Click();
                AssertUrlHasPairingCode(s);
            }
        }
예제 #11
0
        public async Task NewUserLogin()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                //Register & Log Out
                var email = s.RegisterNewUser();
                s.Driver.FindElement(By.Id("Logout")).Click();
                s.Driver.AssertNoError();
                Assert.Contains("Account/Login", s.Driver.Url);
                // Should show the Tor address
                Assert.Contains("wsaxew3qa5ljfuenfebmaf3m5ykgatct3p6zjrqwoouj3foererde3id.onion", s.Driver.PageSource);

                s.Driver.Navigate().GoToUrl(s.Link("/invoices"));
                Assert.Contains("ReturnUrl=%2Finvoices", s.Driver.Url);

                // We should be redirected to login
                //Same User Can Log Back In
                s.Driver.FindElement(By.Id("Email")).SendKeys(email);
                s.Driver.FindElement(By.Id("Password")).SendKeys("123456");
                s.Driver.FindElement(By.Id("LoginButton")).Click();

                // We should be redirected to invoice
                Assert.EndsWith("/invoices", s.Driver.Url);

                // Should not be able to reach server settings
                s.Driver.Navigate().GoToUrl(s.Link("/server/users"));
                Assert.Contains("ReturnUrl=%2Fserver%2Fusers", s.Driver.Url);

                //Change Password & Log Out
                s.Driver.FindElement(By.Id("MySettings")).Click();
                s.Driver.FindElement(By.Id("ChangePassword")).Click();
                s.Driver.FindElement(By.Id("OldPassword")).SendKeys("123456");
                s.Driver.FindElement(By.Id("NewPassword")).SendKeys("abc???");
                s.Driver.FindElement(By.Id("ConfirmPassword")).SendKeys("abc???");
                s.Driver.FindElement(By.Id("UpdatePassword")).Click();
                s.Driver.FindElement(By.Id("Logout")).Click();
                s.Driver.AssertNoError();

                //Log In With New Password
                s.Driver.FindElement(By.Id("Email")).SendKeys(email);
                s.Driver.FindElement(By.Id("Password")).SendKeys("abc???");
                s.Driver.FindElement(By.Id("LoginButton")).Click();
                Assert.True(s.Driver.PageSource.Contains("Stores"), "Can't Access Stores");

                s.Driver.FindElement(By.Id("MySettings")).Click();
                s.ClickOnAllSideMenus();

                s.Driver.Quit();
            }
        }
예제 #12
0
        public async Task CanUsePairing()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.Driver.Navigate().GoToUrl(s.Link("/api-access-request"));
                Assert.Contains("ReturnUrl", s.Driver.Url);

                var alice = s.RegisterNewUser();
                var store = s.CreateNewStore().storeName;
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("Tokens")).Click();
                s.Driver.FindElement(By.Id("CreateNewToken")).Click();
                s.Driver.FindElement(By.Id("RequestPairing")).Click();

                var regex = Regex.Match(new Uri(s.Driver.Url, UriKind.Absolute).Query, "pairingCode=([^&]*)");
                Assert.True(regex.Success, $"{s.Driver.Url} does not match expected regex");
                var pairingCode = regex.Groups[1].Value;

                s.Driver.FindElement(By.Id("ApprovePairing")).Click();
                Assert.Contains(pairingCode, s.Driver.PageSource);

                var client = new NBitpayClient.Bitpay(new Key(), s.Server.PayTester.ServerUri);
                await client.AuthorizeClient(new NBitpayClient.PairingCode(pairingCode));

                await client.CreateInvoiceAsync(new NBitpayClient.Invoice()
                {
                    Price             = 0.000000012m,
                    Currency          = "USD",
                    FullNotifications = true
                }, NBitpayClient.Facade.Merchant);

                client = new NBitpayClient.Bitpay(new Key(), s.Server.PayTester.ServerUri);

                var code = await client.RequestClientAuthorizationAsync("hehe", NBitpayClient.Facade.Merchant);

                s.Driver.Navigate().GoToUrl(code.CreateLink(s.Server.PayTester.ServerUri));
                s.Driver.FindElement(By.Id("ApprovePairing")).Click();

                await client.CreateInvoiceAsync(new NBitpayClient.Invoice()
                {
                    Price             = 0.000000012m,
                    Currency          = "USD",
                    FullNotifications = true
                }, NBitpayClient.Facade.Merchant);
            }
        }
예제 #13
0
        public async Task CanUseDynamicDns()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                var alice = s.RegisterNewUser(isAdmin: true);
                s.Driver.Navigate().GoToUrl(s.Link("/server/services"));
                Assert.Contains("Dynamic DNS", s.Driver.PageSource);

                s.Driver.Navigate().GoToUrl(s.Link("/server/services/dynamic-dns"));
                s.Driver.AssertNoError();
                if (s.Driver.PageSource.Contains("pouet.hello.com"))
                {
                    // Cleanup old test run
                    s.Driver.Navigate().GoToUrl(s.Link("/server/services/dynamic-dns/pouet.hello.com/delete"));
                    s.Driver.FindElement(By.Id("continue")).Click();
                }
                s.Driver.FindElement(By.Id("AddDynamicDNS")).Click();
                s.Driver.AssertNoError();
                // We will just cheat for test purposes by only querying the server
                s.Driver.FindElement(By.Id("ServiceUrl")).SendKeys(s.Link("/"));
                s.Driver.FindElement(By.Id("Settings_Hostname")).SendKeys("pouet.hello.com");
                s.Driver.FindElement(By.Id("Settings_Login")).SendKeys("MyLog");
                s.Driver.FindElement(By.Id("Settings_Password")).SendKeys("MyLog" + Keys.Enter);
                s.Driver.AssertNoError();
                Assert.Contains("The Dynamic DNS has been successfully queried", s.Driver.PageSource);
                Assert.EndsWith("/server/services/dynamic-dns", s.Driver.Url);

                // Try to do the same thing should fail (hostname already exists)
                s.Driver.FindElement(By.Id("AddDynamicDNS")).Click();
                s.Driver.AssertNoError();
                s.Driver.FindElement(By.Id("ServiceUrl")).SendKeys(s.Link("/"));
                s.Driver.FindElement(By.Id("Settings_Hostname")).SendKeys("pouet.hello.com");
                s.Driver.FindElement(By.Id("Settings_Login")).SendKeys("MyLog");
                s.Driver.FindElement(By.Id("Settings_Password")).SendKeys("MyLog" + Keys.Enter);
                s.Driver.AssertNoError();
                Assert.Contains("This hostname already exists", s.Driver.PageSource);

                // Delete it
                s.Driver.Navigate().GoToUrl(s.Link("/server/services/dynamic-dns"));
                Assert.Contains("/server/services/dynamic-dns/pouet.hello.com/delete", s.Driver.PageSource);
                s.Driver.Navigate().GoToUrl(s.Link("/server/services/dynamic-dns/pouet.hello.com/delete"));
                s.Driver.FindElement(By.Id("continue")).Click();
                s.Driver.AssertNoError();

                Assert.DoesNotContain("/server/services/dynamic-dns/pouet.hello.com/delete", s.Driver.PageSource);
            }
        }
예제 #14
0
        public void CanCreateStores()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.Driver.AssertNoError();
                Assert.Contains(store, s.Driver.PageSource);

                s.ClickOnAllSideMenus();

                s.Driver.Quit();
            }
        }
예제 #15
0
        public async Task CanUseCoinSelection()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                var userId  = s.RegisterNewUser(true);
                var storeId = s.CreateNewStore().storeId;
                s.GenerateWallet("BTC", "", false, true);
                var walletId = new WalletId(storeId, "BTC");
                s.GoToWalletReceive(walletId);
                s.Driver.FindElement(By.Id("generateButton")).Click();
                var addressStr = s.Driver.FindElement(By.Id("vue-address")).GetProperty("value");
                var address    = BitcoinAddress.Create(addressStr, ((BTCPayNetwork)s.Server.NetworkProvider.GetNetwork("BTC")).NBitcoinNetwork);
                await s.Server.ExplorerNode.GenerateAsync(1);

                for (int i = 0; i < 6; i++)
                {
                    await s.Server.ExplorerNode.SendToAddressAsync(address, Money.Coins(1.0m));
                }
                var targetTx = await s.Server.ExplorerNode.SendToAddressAsync(address, Money.Coins(1.2m));

                var tx = await s.Server.ExplorerNode.GetRawTransactionAsync(targetTx);

                var spentOutpoint = new OutPoint(targetTx, tx.Outputs.FindIndex(txout => txout.Value == Money.Coins(1.2m)));
                await s.Server.ExplorerNode.GenerateAsync(1);

                s.GoToWalletSend(walletId);
                s.Driver.FindElement(By.Id("advancedSettings")).Click();
                s.Driver.FindElement(By.Id("toggleInputSelection")).Click();
                s.Driver.WaitForElement(By.Id(spentOutpoint.ToString()));
                var el = s.Driver.FindElement(By.Id(spentOutpoint.ToString()));
                s.Driver.FindElement(By.Id(spentOutpoint.ToString())).Click();
                var bob = new Key().PubKey.Hash.GetAddress(Network.RegTest);
                SetTransactionOutput(s, 0, bob, 0.3m);
                s.Driver.FindElement(By.Id("SendMenu")).Click();
                s.Driver.FindElement(By.Id("spendWithNBxplorer")).Click();
                s.Driver.FindElement(By.CssSelector("button[value=broadcast]")).ForceClick();
                var happyElement = s.AssertHappyMessage();
                var happyText    = happyElement.Text;
                var txid         = Regex.Match(happyText, @"\((.*)\)").Groups[1].Value;

                tx = await s.Server.ExplorerNode.GetRawTransactionAsync(new uint256(txid));

                Assert.Single(tx.Inputs);
                Assert.Equal(spentOutpoint, tx.Inputs[0].PrevOut);
            }
        }
예제 #16
0
        public async Task CanUseImplicitFlow()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                var tester = s.Server;

                var user = tester.NewAccount();
                user.GrantAccess();
                var id           = Guid.NewGuid().ToString();
                var redirecturi  = new Uri("http://127.0.0.1/oidc-callback");
                var openIdClient = await user.RegisterOpenIdClient(
                    new OpenIddictApplicationDescriptor()
                {
                    ClientId     = id,
                    DisplayName  = id,
                    Permissions  = { OpenIddictConstants.Permissions.GrantTypes.Implicit },
                    RedirectUris = { redirecturi }
                });

                var implicitAuthorizeUrl = new Uri(tester.PayTester.ServerUri,
                                                   $"connect/authorize?response_type=token&client_id={id}&redirect_uri={redirecturi.AbsoluteUri}&scope=openid&nonce={Guid.NewGuid().ToString()}");
                s.Driver.Navigate().GoToUrl(implicitAuthorizeUrl);
                s.Login(user.RegisterDetails.Email, user.RegisterDetails.Password);
                s.Driver.FindElement(By.Id("consent-yes")).Click();
                var url     = s.Driver.Url;
                var results = url.Split("#").Last().Split("&")
                              .ToDictionary(s1 => s1.Split("=")[0], s1 => s1.Split("=")[1]);
                await TestApiAgainstAccessToken(results["access_token"], tester, user);

                //in Implicit mode, you renew your token  by hitting the same endpoint but adding prompt=none. If you are still logged in on the site, you will receive a fresh token.
                var implicitAuthorizeUrlSilentModel = new Uri($"{implicitAuthorizeUrl.OriginalString}&prompt=none");
                s.Driver.Navigate().GoToUrl(implicitAuthorizeUrlSilentModel);
                url     = s.Driver.Url;
                results = url.Split("#").Last().Split("&").ToDictionary(s1 => s1.Split("=")[0], s1 => s1.Split("=")[1]);
                await TestApiAgainstAccessToken(results["access_token"], tester, user);

                LogoutFlow(tester, id, s);

                s.Driver.Navigate().GoToUrl(implicitAuthorizeUrl);
                s.Login(user.RegisterDetails.Email, user.RegisterDetails.Password);

                Assert.Throws <NoSuchElementException>(() => s.Driver.FindElement(By.Id("consent-yes")));
                results = url.Split("#").Last().Split("&")
                          .ToDictionary(s1 => s1.Split("=")[0], s1 => s1.Split("=")[1]);
                await TestApiAgainstAccessToken(results["access_token"], tester, user);
            }
        }
예제 #17
0
        public async Task CanHandleRefundEmailForm()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme("BTC");
                s.GoToStore(store.storeId, StoreNavPages.Checkout);
                s.Driver.FindElement(By.Id("RequiresRefundEmail")).Click();
                s.Driver.FindElement(By.Name("command")).Click();

                var emailAlreadyThereInvoiceId = s.CreateInvoice(store.storeName, 100, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(emailAlreadyThereInvoiceId);
                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
                s.GoToHome();
                var invoiceId = s.CreateInvoice(store.storeName);
                s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
                s.Driver.AssertNoError();
                s.Driver.Navigate().Back();
                s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
                Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));

                Assert.True(s.Driver.FindElement(By.Id("emailAddressFormInput")).Displayed);
                s.Driver.FindElement(By.Id("emailAddressFormInput")).SendKeys("xxx");
                s.Driver.FindElement(By.Id("emailAddressForm")).FindElement(By.CssSelector("button.action-button"))
                .Click();
                var formInput = s.Driver.FindElement(By.Id("emailAddressFormInput"));

                Assert.True(formInput.Displayed);
                Assert.Contains("form-input-invalid", formInput.GetAttribute("class"));
                formInput = s.Driver.FindElement(By.Id("emailAddressFormInput"));
                formInput.SendKeys("@g.com");
                var actionButton = s.Driver.FindElement(By.Id("emailAddressForm")).FindElement(By.CssSelector("button.action-button"));
                actionButton.Click();
                try // Sometimes the click only take the focus, without actually really clicking on it...
                {
                    actionButton.Click();
                }
                catch { }

                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
                s.Driver.Navigate().Refresh();
                s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
            }
        }
예제 #18
0
        public async Task CanUsePaymentMethodDropdown()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Server.ActivateLTC();
                s.Server.ActivateLightning();
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme("BTC");

                //check that there is no dropdown since only one payment method is set
                var invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(invoiceId);
                s.Driver.FindElement(By.ClassName("payment__currencies_noborder"));
                s.GoToHome();
                s.GoToStore(store.storeId);
                s.AddDerivationScheme("LTC");
                s.AddLightningNode("BTC", LightningConnectionType.CLightning);
                //there should be three now
                invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(invoiceId);
                var currencyDropdownButton = s.Driver.FindElement(By.ClassName("payment__currencies"));
                Assert.Contains("BTC", currencyDropdownButton.Text);
                currencyDropdownButton.Click();

                var elements = s.Driver.FindElement(By.ClassName("vex-content")).FindElements(By.ClassName("vexmenuitem"));
                Assert.Equal(3, elements.Count);
                elements.Single(element => element.Text.Contains("LTC")).Click();
                Thread.Sleep(1000);
                currencyDropdownButton = s.Driver.FindElement(By.ClassName("payment__currencies"));
                Assert.Contains("LTC", currencyDropdownButton.Text);
                currencyDropdownButton.Click();

                elements = s.Driver.FindElement(By.ClassName("vex-content")).FindElements(By.ClassName("vexmenuitem"));
                elements.Single(element => element.Text.Contains("Lightning")).Click();
                Thread.Sleep(1000);
                currencyDropdownButton = s.Driver.FindElement(By.ClassName("payment__currencies"));

                Assert.Contains("Lightning", currencyDropdownButton.Text);

                s.Driver.Quit();
            }
        }
예제 #19
0
        public void CanManageWallet()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                s.CreateNewStore();
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("Wallets")).Click();
                s.Driver.FindElement(By.LinkText("Manage")).Click();

                s.ClickOnAllSideMenus();

                s.Driver.Quit();
            }
        }
예제 #20
0
        public void CanCreateInvoice()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("Invoices")).Click();
                s.Driver.FindElement(By.Id("CreateNewInvoice")).Click();
                s.Driver.FindElement(By.CssSelector("input#Amount.form-control")).SendKeys("100");
                s.Driver.FindElement(By.Name("StoreId")).SendKeys(store + Keys.Enter);
                s.Driver.FindElement(By.Id("Create")).Click();
                Assert.True(s.Driver.PageSource.Contains("just created!"), "Unable to create Invoice");
                s.Driver.Quit();
            }
        }
예제 #21
0
        public void CanUseLightningSatsFeature()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddInternalLightningNode("BTC");
                s.GoToStore(store.storeId, StoreNavPages.Checkout);
                s.SetCheckbox(s, "LightningAmountInSatoshi", true);
                var command = s.Driver.FindElement(By.Name("command"));

                command.ForceClick();
                var invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(invoiceId);
                Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
            }
        }
예제 #22
0
        public async Task CanNavigateServerSettings()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.RegisterNewUser(true);
                s.Driver.FindElement(By.Id("ServerSettings")).Click();
                s.Driver.AssertNoError();
                s.ClickOnAllSideMenus();
                s.Driver.FindElement(By.LinkText("Services")).Click();

                Logs.Tester.LogInformation("Let's check if we can access the logs");
                s.Driver.FindElement(By.LinkText("Logs")).Click();
                s.Driver.FindElement(By.PartialLinkText(".log")).Click();
                Assert.Contains("Starting listening NBXplorer", s.Driver.PageSource);
                s.Driver.Quit();
            }
        }
예제 #23
0
        public async Task CanSetupEmailServer()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                var alice = s.RegisterNewUser(isAdmin: true);
                s.Driver.Navigate().GoToUrl(s.Link("/server/emails"));
                if (s.Driver.PageSource.Contains("Configured"))
                {
                    s.Driver.FindElement(By.CssSelector("button[value=\"ResetPassword\"]")).Submit();
                    s.AssertHappyMessage();
                }
                CanSetupEmailCore(s);
                s.CreateNewStore();
                s.GoToUrl($"stores/{s.StoreId}/emails");
                CanSetupEmailCore(s);
            }
        }
예제 #24
0
        public void CanCreateInvoice()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.AddDerivationScheme();

                CreateInvoice(s, store);

                s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
                s.Driver.AssertNoError();
                s.Driver.Navigate().Back();
                s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
                Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
                s.Driver.Quit();
            }
        }
예제 #25
0
        public void CanCreateAppPoS()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                var store = s.CreateNewStore();

                s.Driver.FindElement(By.Id("Apps")).Click();
                s.Driver.FindElement(By.Id("CreateNewApp")).Click();
                s.Driver.FindElement(By.Name("Name")).SendKeys("PoS" + store);
                s.Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("PointOfSale" + Keys.Enter);
                s.Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys(store + Keys.Enter);
                s.Driver.FindElement(By.Id("Create")).Click();
                s.Driver.FindElement(By.CssSelector("input#EnableShoppingCart.form-check")).Click();
                s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
                Assert.True(s.Driver.PageSource.Contains("App updated"), "Unable to create PoS");
                s.Driver.Quit();
            }
        }
예제 #26
0
        public async Task CanSetDefaultPaymentMethod()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Server.ActivateLightning();
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser(true);
                var store = s.CreateNewStore();
                s.AddLightningNode();
                s.AddDerivationScheme("BTC");

                var invoiceId = s.CreateInvoice(store.storeName, defaultPaymentMethod: "BTC_LightningLike");
                s.GoToInvoiceCheckout(invoiceId);

                Assert.Equal("Bitcoin (Lightning) (BTC)", s.Driver.FindElement(By.ClassName("payment__currencies")).Text);
                s.Driver.Quit();
            }
        }
예제 #27
0
        public async Task CanUseSSHService()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                var alice = s.RegisterNewUser(isAdmin: true);
                s.Driver.Navigate().GoToUrl(s.Link("/server/services"));
                Assert.Contains("server/services/ssh", s.Driver.PageSource);
                using (var client = await s.Server.PayTester.GetService <BTCPayServer.Configuration.BTCPayServerOptions>().SSHSettings.ConnectAsync())
                {
                    var result = await client.RunBash("echo hello");

                    Assert.Equal(string.Empty, result.Error);
                    Assert.Equal("hello\n", result.Output);
                    Assert.Equal(0, result.ExitStatus);
                }
                s.Driver.Navigate().GoToUrl(s.Link("/server/services/ssh"));
                s.Driver.AssertNoError();
            }
        }
예제 #28
0
        public async Task CanUseLightningSatsFeature()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Server.ActivateLightning();
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser(true);
                var store = s.CreateNewStore();
                s.AddLightningNode();
                s.GoToStore(store.storeId);
                s.Driver.SetCheckbox(By.Id("LightningAmountInSatoshi"), true);
                s.Driver.FindElement(By.Id("Save")).Click();
                Assert.Contains("Store successfully updated", s.FindAlertMessage().Text);

                var invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "*****@*****.**");
                s.GoToInvoiceCheckout(invoiceId);
                Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
            }
        }
예제 #29
0
        public void CanCreatePayRequest()
        {
            using (var s = SeleniumTester.Create())
            {
                s.Start();
                s.RegisterNewUser();
                s.CreateNewStore();
                s.AddDerivationScheme();

                s.Driver.FindElement(By.Id("PaymentRequests")).Click();
                s.Driver.FindElement(By.Id("CreatePaymentRequest")).Click();
                s.Driver.FindElement(By.Id("Title")).SendKeys("Pay123");
                s.Driver.FindElement(By.Id("Amount")).SendKeys("700");
                s.Driver.FindElement(By.Id("Currency")).SendKeys("BTC");
                s.Driver.FindElement(By.Id("SaveButton")).Submit();
                s.Driver.FindElement(By.Name("ViewAppButton")).SendKeys(Keys.Return);
                s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
                Assert.True(s.Driver.PageSource.Contains("Amount due"), "Unable to create Payment Request");
                s.Driver.Quit();
            }
        }
예제 #30
0
        public async Task CanUseJSModal()
        {
            using (var s = SeleniumTester.Create())
            {
                await s.StartAsync();

                s.GoToRegister();
                s.RegisterNewUser();
                var store = s.CreateNewStore();
                s.GoToStore(store.storeId);
                s.AddDerivationScheme();
                var invoiceId = s.CreateInvoice(store.storeId, 0.001m, "BTC", "*****@*****.**");
                var invoice   = await s.Server.PayTester.InvoiceRepository.GetInvoice(invoiceId);

                s.Driver.Navigate()
                .GoToUrl(new Uri(s.Server.PayTester.ServerUri, $"tests/index.html?invoice={invoiceId}"));
                TestUtils.Eventually(() =>
                {
                    Assert.True(s.Driver.FindElement(By.Name("btcpay")).Displayed);
                });
                await s.Server.ExplorerNode.SendToAddressAsync(BitcoinAddress.Create(invoice
                                                                                     .GetPaymentMethod(new PaymentMethodId("BTC", PaymentTypes.BTCLike))
                                                                                     .GetPaymentMethodDetails().GetPaymentDestination(), Network.RegTest),
                                                               new Money(0.001m, MoneyUnit.BTC));

                IWebElement closebutton = null;
                TestUtils.Eventually(() =>
                {
                    var frameElement = s.Driver.FindElement(By.Name("btcpay"));
                    var iframe       = s.Driver.SwitchTo().Frame(frameElement);
                    closebutton      = iframe.FindElement(By.ClassName("close-action"));
                    Assert.True(closebutton.Displayed);
                });
                closebutton.Click();
                s.Driver.AssertElementNotFound(By.Name("btcpay"));
                Assert.Equal(s.Driver.Url,
                             new Uri(s.Server.PayTester.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString());
            }
        }