feat: open payto links on the pay form, and take the checkout over D-Bus out

An app could have nostrod pay an order: it called Pay of
net.catcrafts.Nostro1.Checkout on the system bus, and nostrod paid from
an account the user had chosen, after a dialog of its own. On 2026-11-22
the owner decided that a link takes its place. The app registers for
payto links (RFC 8905), so that an app or a website can hand one to the
desktop, and shows a link as its pay form filled in.

The link:

- The app's desktop entry takes the scheme (Exec=nostro-app %u,
  MimeType=x-scheme-handler/payto), and nostro-app takes an argument
  that is no option as a link: it overwrites it in argv and hands it to
  App::Open once the app has started.
- ReadPaymentLink (Nostro.App:Forms) reads payto://iban/<IBAN> with the
  options amount, receiver-name and message, and refuses a link rather
  than guess at it, in a sentence of the app's own with nothing of the
  link in it. Among what it refuses: an IBAN whose check digits do not
  hold, one of the three options given twice, instruction, a comma in
  the amount, and a name or a message with a code point that is Unshown,
  or Blank and no plain space.
- A link that is read waits until the accounts are read and
  DefaultCheckoutAccount has answered or failed, with a line on the
  accounts' page. Then App::TakeLink fills in the pay form, which says
  in a banner that a link filled it in, and with more than one account
  opens it under the choice of accounts that the form's From row has. A
  link pays nothing: the form's button sends, and polkit's dialog
  confirms as for any payment (design rule 12, and 14, which is new).
- Unshown and Blank are the two tables the worker's Shown() works from.
  They move into Nostro:Utils, where the app's reader asks them too.
  The move is within the library. The reader holds a link's name to
  those two and to no more of Shown(): a name with an & is read, and
  the dialog shows it with a + as it does any name.

The checkout:

- nostrod serves one interface under one bus name. Gone are
  net.catcrafts.Nostro1.Checkout with its XML and its activation file,
  the polkit action Checkout, the module Nostro.Checkout with
  --product=checkout, and the worker's record of orders. That changes
  the published contract after a release, 0.0.0, and design rule 10
  records it as the owner's decision.
- DefaultCheckoutAccount and SetDefaultCheckoutAccount keep their names
  and signatures. The account they keep is where a link's pay form
  starts: nostrod's dialog for choosing it says "have pay links start
  from", the app's setting reads "Pay links start from", and `nostro
  checkout account` prints "pay links start from".
- The D-Bus policy still lets nostrod own the old name: the nostrod of
  0.0.0 asks for it when it starts, and the system files can be newer
  than the Flatpak it runs from. install.sh removes the old name's
  activation file. A user's checkouts.cdb is read by nothing any more,
  and is left where it is.
- The Arch package stops installing the checkout's two files, and its
  pkgrel goes up to 2. Where makepkg -si finds a package of the version
  already built it installs that one again, which would bring the
  activation file back. The guide now says that pkgrel goes up with a
  change to what the package installs.
- Bus::Interface goes too: the worker called it in two places, to tell
  a call to the checkout from one to the main interface.

The review's own files follow. gate0 loses the build of
--product=checkout, and the three lens sections that named the checkout
no longer do, and ask about a link.

The README has "Pay links" in place of "Checkout for apps", and
AGENTS.consumer.md says what the app reads of a link. Its line on
lib/json.hpp no longer gives a release: the file is of none, and the
guide names its commit. The pay form and the accounts' page change only
by a banner each, shown while a link is in play, which
docs/screenshots/take.sh never has: the README's pictures stand.

Tests: ShouldValidateForms reads and refuses links and fills the form
from one. ShouldDriveTheApp opens links against a real nostrod on the
fake bus: before the accounts are known, with no account, with one and
with several, with the accounts known and the system bus gone, for a
second user whose first connection pays their own accounts only, one
that cannot be read, one whose name has an &, and through polkit's
dialog to the payment. It now counts nostrod's answers to hold that the
account pay links start from is read again once a connection is
removed: the check it had there passed without that.
ShouldHandleMoneyAndText holds the two tables at the ends of their
ranges. ShouldServeEveryUser holds that nostrod serves no checkout, that
the bus's policy lets an older nostrod own the old name, and the account
pay links start from. ShouldRunCommands holds the CLI's wording.

The review's gate0 passes at this commit: the version check, 17 tests,
the builds of the CLI, the library, nostrod, the fake system, the app
and its --debug-api build, and five lint runs that report nothing.
tests/coverage.sh reports lines, functions and regions at 100.00%.

Looked at on 2026-11-22 on the made-up system (run fake), on a desktop
(KWin at a scale of 1.85). At 420x760, at --scale 3 --size 360x760 and
at 1100x720 in the light look: a link's pay form under the choice of
accounts, the form after a tap beside that choice, and the accounts'
page while a link waits, its line above the rows that stand in for the
accounts (--bank-delay 10000). At 420x760: that line above what the
page says when the accounts cannot be read (--polkit deny) and above
the accounts themselves (--polkit slow, the link opened in the running
app), the settings' row and page for the account pay links start from,
the sheet for a link that cannot be read, and with --empty the sheet
for no account.
This commit is contained in:
Jorijn van der Graaf 2026-11-22 13:35:51 +01:00
commit b43ab124a6
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
42 changed files with 1234 additions and 994 deletions

View file

@ -53,6 +53,8 @@ namespace fs = std::filesystem;
namespace {
constexpr std::uint16_t port = 47307;
constexpr std::uint32_t uid = 4242;
// A second user of the machine, with connections of their own.
constexpr std::uint32_t erinUid = 4243;
constexpr std::string_view busName = "net.catcrafts.Nostro1";
const std::string aliceKey = "key-alice-0123456789abcdef";
const std::string aliceMain = "NL23BUNQ2025123456";
@ -63,6 +65,8 @@ namespace {
const std::string daveIban = "NL06BUNQ2025444444";
const std::string otherAliceIban = "NL25BUNQ2025555555";
const std::string strangerIban = "NL44BUNQ2025666666";
// A link as a website's pay button opens one: to Bob's account, under a shop's name, with what is owed and for what.
const std::string shopLink = std::format("payto://iban/{}?amount=EUR:12.50&receiver-name=Shop%20BV&message=Order%201234", bobIban);
void SetPolkit(Fake::Bus& bus, Fake::Polkit outcome, std::string_view action = {}) {
std::lock_guard lock(bus.mutex);
@ -313,6 +317,26 @@ namespace {
return change == std::views::reverse(bus.checks).end() ? std::string() : change->action;
}
// What the system's dialog said that change was: nostrod's own words for it, from its own data.
std::string Summary(Fake::Bus& bus) {
std::lock_guard lock(bus.mutex);
const auto change = std::ranges::find_if(std::views::reverse(bus.checks), [](const Fake::PolkitCheck& check) { return check.action != Bus::actionView; });
return change == std::views::reverse(bus.checks).end() || !change->details.contains("summary") ? std::string() : change->details.at("summary");
}
// How often polkit was asked about a change: what a screen reads is a check too, for looking.
std::size_t Changes(Fake::Bus& bus) {
std::lock_guard lock(bus.mutex);
return static_cast<std::size_t>(std::ranges::count_if(bus.checks, [](const Fake::PolkitCheck& check) { return check.action != Bus::actionView; }));
}
// What the bank was last sent as a payment or a draft of one.
std::string LastPayment(Fake::Bunq& bunq) {
const std::vector<Fake::Logged> log = bunq.Log();
const auto sent = std::ranges::find_if(std::views::reverse(log), [](const Fake::Logged& entry) { return entry.method == "POST" && entry.path.contains("payment"); });
return sent == std::views::reverse(log).end() ? std::string() : sent->body;
}
// Before nostrod runs: no system bus at all, then a bus without nostrod, then nostrod without a connection.
void Starting(Driver& d, pid_t& nostrod, const fs::path& state) {
d.noBus = true;
@ -339,6 +363,18 @@ namespace {
Check(Has(d, "nav.accounts") && Has(d, "nav.cards") && Has(d, "nav.settings"), "the app's places are along the bottom");
Equal(d.connects, 2, "one connection to the bus is all it took");
// A link that asks for a payment, and no account to pay it from: that is said, and no form is opened.
Check(d.app.Open(shopLink), "a link is taken");
Settle(d);
Equal(d.app.Screen(), std::string("accounts+link"), "a link opens no form where there is no account to pay from");
Shows(d.ui, "No account to pay from", "which is said");
Shows(d.ui, "This link asks for a payment", "with what the link was for");
Hides(d.ui, "Shop BV", "and with nothing of what the link said");
Tap(d, "link.close");
Equal(d.app.Screen(), std::string("accounts"), "closed, it leaves the welcome");
Shows(d.ui, "Welcome to Nostro", "where a bank can be connected");
Hides(d.ui, "A link asks for a payment", "and the link waits for nothing");
// Every place says so when it has nothing to show.
Press(d, "nav.cards");
Shows(d.ui, "No cards", "no cards");
@ -348,7 +384,7 @@ namespace {
Shows(d.ui, "No bank is connected yet", "none to list");
Tap(d, "bar.back");
Tap(d, "settings.checkout");
Shows(d.ui, "No accounts to choose from", "and no account to pay at checkout from");
Shows(d.ui, "No accounts to choose from", "and no account for a pay link to start from");
Tap(d, "bar.back");
Tap(d, "nav.accounts");
// A connection without an account: there is nothing to pay from.
@ -366,6 +402,19 @@ namespace {
other.RemoveConnector("Eve");
Press(d, "bar.refresh");
Shows(d.ui, "Welcome to Nostro", "without it the welcome is back");
// One account in all: a link's form opens from it at once, since there is nothing to choose between.
other.AddBunq(daveKey, "*", "");
Press(d, "bar.refresh");
Shows(d.ui, "Play money", "a single account");
Check(d.app.Open(shopLink), "a link is taken");
Build(d);
Equal(d.app.Screen(), std::string("pay"), "with one account a link opens its form without asking which account pays");
Shows(d.ui, "Play money", "from the one there is");
Shows(d.ui, "Shop BV", "filled in");
Tap(d, "bar.back");
other.RemoveConnector("Dave");
Press(d, "bar.refresh");
Shows(d.ui, "Welcome to Nostro", "and with that account gone the welcome is back");
// Connecting a bank from there: which bank first, then how, and then the form of that way.
Check(Has(d, "welcome.connect") && d.ui.Find("welcome.connect")->label == "Connect a bank", "which offers to connect a bank, whichever");
Tap(d, "welcome.connect");
@ -450,7 +499,7 @@ namespace {
Hides(d.ui, "Welcome to Nostro", "the welcome is over");
Check(Has(d, "home.pay") && Has(d, "home.request"), "paying and asking are at hand");
Tap(d, "nav.settings");
Shows(d.ui, "No account chosen", "no account pays at checkout yet");
Shows(d.ui, "No account chosen", "no account is chosen for pay links to start from yet");
Tap(d, "settings.connections");
Check(Has(d, "connections.add") && d.ui.Find("connections.add")->label == "Add a connection", "the settings add a connection too, of whichever bank");
Adding(d, "key");
@ -811,6 +860,7 @@ namespace {
d.ui.KeyDown(Key::Escape, {});
Check(!d.ui.Tap("pay.submit") && !d.ui.Tap("bar.back") && d.ui.Focused().empty(), "under which the form is out of reach: of a finger, and of the key that sent it");
Check(!d.app.Navigate("cards") && d.app.Screen() == "pay+working", "nor is the screen left by name while it is under way");
Check(!d.app.Open(shopLink) && d.app.Screen() == "pay+working", "or for a link that asks for another payment");
Settle(d);
Shows(d.ui, "Paid €12.50 to Bob", "the payment made is said");
Check(Has(d, "copy.Payment") && !Test::Says(d.ui, "Press a line to copy it"), "with the bank's number of it, which can be copied without a word about it");
@ -906,6 +956,27 @@ namespace {
Equal(d.app.Screen(), page, "which shows the account");
Shows(d.ui, "Today", "and its payments");
Tap(d, "bar.back");
// A link that asks for a payment, while no account is chosen for links to start from: its form starts from
// the first account that pays anyone, which the bank lists the savings as, whichever account paid last. Which
// account pays is the first thing asked, over the form, and a tap beside the question keeps that one.
Tap(d, "home.pay");
Shows(d.ui, "Main", "the pay form pays from the account that paid last");
Tap(d, "bar.back");
Check(d.app.Open(shopLink), "a link is taken");
Build(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "and opens the pay form, with the choice of the account that pays over it");
Shows(d.ui, "Choose an account", "which asks for one");
Check(Has(d, std::format("pick.{}", aliceMain)) && Has(d, std::format("pick.{}", aliceSavings)), "of every account there is");
Check(!d.ui.Tap("pay.submit") && !d.ui.Tap("bar.back"), "and covers the form, its button too");
TapBeside(d);
Equal(d.app.Screen(), std::string("pay"), "a tap beside it leaves the form");
Shows(d.ui, "Savings", "paying from the first account, where none was chosen for links to start from");
Hides(d.ui, "Main", "not from the one the form paid from last");
Tap(d, "pay.from");
Tap(d, std::format("pick.{}", aliceMain));
Tap(d, "bar.back");
Equal(d.app.Screen(), std::string("accounts"), "the way back from it leads to the accounts");
}
// Asking for money, and the request sent looked at and revoked.
@ -1300,11 +1371,11 @@ namespace {
Tap(d, "nav.accounts");
}
// The settings: the account that pays at checkout, what the app is, and the connections, removed by name and,
// where two have one name, by number.
// The settings: the account a pay link's form starts from, what the app is, and the connections, removed by name
// and, where two have one name, by number.
void Settings(Driver& d, Fake::Bus& bus, Fake::Bunq& bunq) {
Tap(d, "nav.settings");
for(const std::string_view said : {"Bank connections", "2 connected", "Pay at checkout from", "No account chosen", "About and security", "Nostro 1.2.3"}) {
for(const std::string_view said : {"Bank connections", "2 connected", "Pay links start from", "No account chosen", "About and security", "Nostro 1.2.3"}) {
Shows(d.ui, said, "the settings are listed");
}
Tap(d, "settings.about");
@ -1316,15 +1387,19 @@ namespace {
Tap(d, "bar.back");
Tap(d, "settings.checkout");
Equal(d.app.Screen(), std::string("checkout"), "the account that pays at checkout has a page");
Shows(d.ui, "Play money", "which lists the accounts");
Equal(d.app.Screen(), std::string("checkout"), "the account pay links start from has a page");
Shows(d.ui, "Pay links", "called after what it is for");
Shows(d.ui, "A shop's pay link opens Nostro", "which says what a pay link is");
Shows(d.ui, "choose another one", "and that the account is only where its form starts");
Shows(d.ui, "Play money", "and lists the accounts");
SetPolkit(bus, Fake::Polkit::Password, Bus::actionConnectors);
Tap(d, std::format("checkout.{}", aliceMain));
Shows(d.ui, "Letting apps ask you to pay from Main", "choosing one is under way");
Shows(d.ui, "Having pay links start from Main", "choosing one is under way");
Shows(d.ui, "Confirm it in your system's password dialog.", "and needs the password");
Settle(d);
Shows(d.ui, "Apps now ask you to pay from Main", "the choice is said");
Shows(d.ui, "Pay links now start from Main", "the choice is said");
Equal(Action(bus), std::string(Bus::actionConnectors), "after the password for changing connections");
Equal(Summary(bus), std::format("have pay links start from {} (Main)", aliceMain), "which the system's dialog asked for in nostrod's words for it");
Tap(d, "bar.back");
Shows(d.ui, std::format("Main · {}", GroupIban(aliceMain)), "and shown in the settings");
@ -1350,6 +1425,7 @@ namespace {
Shows(d.ui, "The API key itself stays valid", "with what stays valid at its bank, by the way it was connected");
Tap(d, "confirm.no");
Equal(d.app.Screen(), std::string("connections"), "and can be thought better of");
const std::size_t reads = Answers(d, "DefaultCheckoutAccount ok");
Tap(d, dave);
Tap(d, "detail.remove");
Tap(d, "confirm.yes");
@ -1360,7 +1436,7 @@ namespace {
Check(!Has(d, dave), "and no longer listed");
Tap(d, "bar.back");
Shows(d.ui, "1 connected", "one is left");
Shows(d.ui, "Pay at checkout from", "and the checkout's account is read again");
Equal(Answers(d, "DefaultCheckoutAccount ok"), reads + 1, "and the account pay links start from is read again: the connection may have held it");
// Two connections of one name: the one to remove is told apart by its accounts, and removed by its number.
Client other = Client::System();
@ -1548,12 +1624,301 @@ namespace {
Tap(d, "bar.back");
Tap(d, "nav.settings");
Tap(d, "settings.checkout");
Check(!d.ui.Find(std::format("checkout.{}", carolIban))->enabled && d.ui.Find(std::format("checkout.{}", aliceMain))->enabled, "nor can it pay at a checkout");
Check(!d.ui.Find(std::format("checkout.{}", carolIban))->enabled && d.ui.Find(std::format("checkout.{}", aliceMain))->enabled, "nor can a pay link be set to start from it");
Shows(d.ui, "Pays your own accounts only", "which is said");
Tap(d, "bar.back");
Tap(d, "nav.accounts");
}
// A link that asks for a payment, as a website's pay button opens one. It fills in the pay form and does no more:
// whoever wrote it chose the payee and the amount, so nothing is sent before the user presses the form's button
// and the system's password dialog has said, in nostrod's own words, what is paid to whom.
void Linking(Driver& d, Fake::Bus& bus, Fake::Bunq& bunq) {
// One the app cannot read is said to be so over wherever the user is, with why, in the app's own words.
Check(d.app.Open("payto://iban/NL00MARK?message=MARK"), "a link that cannot be read is taken all the same");
Build(d);
Equal(d.app.Screen(), std::string("accounts+link"), "and said to be one, over the accounts");
Shows(d.ui, "This link cannot be opened", "by name");
Shows(d.ui, "The IBAN in it is not a valid one.", "with why");
Hides(d.ui, "MARK", "and with nothing of the link itself");
TapBeside(d);
Equal(d.app.Screen(), std::string("accounts"), "a tap beside it closes it");
Check(d.app.Navigate("cards"), "the cards");
Settle(d);
Check(d.app.Open("https://example.org/pay"), "any other address is no payment");
Build(d);
Equal(d.app.Screen(), std::string("cards+link"), "which is said over the place the user is at: nothing is gone to for it");
Shows(d.ui, "It is not a link to pay an IBAN", "with why");
Tap(d, "link.close");
Equal(d.app.Screen(), std::string("cards"), "and closed again");
// A link that can be read, from a page gone into: the pay form, filled in, and nothing asked or sent. Which
// account pays is asked first, over the form, with the one chosen for pay links to start from as what the
// form holds: Main, since the settings were gone through, which is not the account the bank lists first.
Tap(d, "nav.settings");
Tap(d, "settings.checkout");
Equal(d.app.Screen(), std::string("checkout"), "a page of the settings");
const std::size_t posts = bunq.Count("POST", "/user/");
const std::size_t changes = Changes(bus);
Check(d.app.Open(shopLink), "a link is taken from wherever the user is");
Build(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "and opens the pay form, asking first which account pays");
Shows(d.ui, "Choose an account", "in a list of the accounts");
Check(Has(d, std::format("pick.{}", aliceMain)) && Has(d, std::format("pick.{}", aliceSavings)) && Has(d, std::format("pick.{}", carolIban)), "every one of them, whichever connection it is of");
Shows(d.ui, "A link filled this in, not you.", "the form under it says that a link filled it in");
for(const std::string_view said : {std::string_view(bobIban), std::string_view("Shop BV"), std::string_view("12.50"), std::string_view("Order 1234")}) {
Shows(d.ui, said, "with what the link said, in the form's own fields");
}
// The question covers the form, as any sheet covers its page: the form's button cannot be pressed through it,
// by a finger or by a key.
d.ui.KeyDown(Key::Enter, {});
d.ui.KeyDown(Key::Space, {});
Check(!d.ui.Tap("pay.submit") && !d.ui.Tap("bar.back") && !d.ui.Tap("pay.to"), "the form is out of reach until the account is settled");
Settle(d);
Check(d.app.Screen() == "pay+accounts" && bunq.Count("POST", "/user/") == posts && Changes(bus) == changes && !d.app.Changing(), "nothing is sent, and the user is asked for no password: a link fills in a form");
d.ui.KeyDown(Key::Escape, {});
Build(d);
Equal(d.app.Screen(), std::string("pay"), "Escape leaves the question");
Shows(d.ui, "Main", "and the form paying from the account chosen for pay links to start from");
Hides(d.ui, "Savings", "not from the first one");
Bottom(d);
Equal(d.ui.Find("pay.submit")->label, std::string("Pay"), "its button pays, as any pay form's does");
// The system's password dialog is where it is confirmed. Closed, nothing is paid, and the form is still the link's.
SetPolkit(bus, Fake::Polkit::Dismiss, Bus::actionPay);
Press(d, "pay.submit");
Equal(d.app.Screen(), std::string("pay+problem"), "the button sends it to that dialog, with no question of the app's own before it");
Shows(d.ui, "Not confirmed", "and a dialog closed is a payment not made");
Equal(bunq.Count("POST", "/user/"), posts, "of which the bank hears nothing");
Equal(Summary(bus), std::format("pay €12.50 to {} (Shop BV) from {} (Main)", bobIban, aliceMain), "the dialog said what the link asks for in nostrod's own words: the amount, the address before the name, and the account the form showed");
Press(d, "problem.close");
Top(d);
Shows(d.ui, "A link filled this in, not you.", "the form is still said to be a link's");
Shows(d.ui, "Order 1234", "and is as the link filled it in");
SetPolkit(bus, Fake::Polkit::Password, Bus::actionPay);
Bottom(d);
Press(d, "pay.submit");
Shows(d.ui, "Paid €12.50 to Shop BV", "confirmed there, it is paid");
Equal(Action(bus), std::string(Bus::actionPay), "after the password for paying");
Equal(bunq.Count("POST", "/user/"), posts + 1, "once");
const std::string sent = LastPayment(bunq);
Check(sent.contains(bobIban) && sent.contains("Shop BV") && sent.contains("12.50") && sent.contains("Order 1234"), "and the bank is sent what the form showed");
Press(d, "done.close");
Equal(d.app.Screen(), std::string("accounts"), "which leads to the accounts");
Tap(d, "home.pay");
Hides(d.ui, "A link filled this in", "the next pay form is nobody's but the user's");
Hides(d.ui, "Order 1234", "and empty");
Tap(d, "bar.back");
// An account picked from the choice a link opens with is the one that pays: the form shows it, and the
// system's dialog names it. A tap beside the choice, like Escape, keeps the one the form started from.
Check(d.app.Open(shopLink), "the link again");
Tap(d, std::format("pick.{}", aliceSavings));
Equal(d.app.Screen(), std::string("pay"), "an account picked there closes the choice");
Shows(d.ui, "Savings", "and is the one the form pays from");
Hides(d.ui, "Main", "in place of the one it started from");
Shows(d.ui, "A link filled this in, not you.", "which leaves the form a link's");
SetPolkit(bus, Fake::Polkit::Dismiss, Bus::actionPay);
Bottom(d);
Press(d, "pay.submit");
Equal(Summary(bus), std::format("pay €12.50 to {} (Shop BV) from {} (Savings)", bobIban, aliceSavings), "the dialog names the account that was picked");
SetPolkit(bus, Fake::Polkit::Password, Bus::actionPay);
Press(d, "problem.close");
Tap(d, "bar.back");
Check(d.app.Open(shopLink), "and again");
TapBeside(d);
Equal(d.app.Screen(), std::string("pay"), "a tap beside the choice closes it too");
Shows(d.ui, "Main", "with the account the form started from");
Tap(d, "bar.back");
// A link that says no more than who is paid: the rest is the user's to fill in, and the form is checked as any.
Check(d.app.Open(std::format("payto://iban/{}", bobIban)), "a link with an IBAN alone");
TapBeside(d);
Shows(d.ui, bobIban, "fills in who is paid");
Bottom(d);
Tap(d, "pay.submit");
Top(d);
Shows(d.ui, "The name of the account's holder", "and its form still lacks a name");
Shows(d.ui, "Enter an amount", "and an amount");
Check(!d.app.Changing() && bunq.Count("POST", "/user/") == posts + 1, "so nothing is sent");
Tap(d, "bar.back");
// A name with an & in it, which the system's dialog does not show as it is: the form and the bank have the
// link's name, and the dialog has it the way nostrod makes any name fit to show there, after the IBAN.
Check(d.app.Open(std::format("payto://iban/{}?amount=EUR:1&receiver-name=Fish%20%26%20Chips", bobIban)), "a link whose name has an &");
TapBeside(d);
Shows(d.ui, "Fish & Chips", "has that name on its form as the link has it");
Bottom(d);
Press(d, "pay.submit");
Shows(d.ui, "Paid €1.00 to Fish & Chips", "and is paid under it");
Equal(Summary(bus), std::format("pay €1.00 to {} (Fish + Chips) from {} (Main)", bobIban, aliceMain), "the dialog showed the name in nostrod's way, after the IBAN it shows whole");
Check(LastPayment(bunq).contains("Fish & Chips"), "and the bank is sent the name as the form had it");
Press(d, "done.close");
// From an account whose connection pays between the user's own accounts only, what a link asks for is saved as
// a draft, as anything paid to someone else from there is. The choice a link opens with offers that account
// too, as the form's own does.
Check(d.app.Open(shopLink), "the link again");
Tap(d, std::format("pick.{}", carolIban));
Shows(d.ui, "A payment to anyone else", "the form says what becomes of it from such an account");
Bottom(d);
Equal(d.ui.Find("pay.submit")->label, std::string("Save as draft"), "and its button that it saves a draft");
Press(d, "pay.submit");
Shows(d.ui, "Drafted €12.50 to Shop BV", "which it does");
Equal(Action(bus), std::string(Bus::actionChange), "as a change that moves no money");
Press(d, "done.close");
// A wide window has the app's places beside every page. A link's form left sideways is not opened again by
// itself, and when the user goes back to it, what it holds is still said to be a link's.
d.size = {0, 0, 1280, 800};
Check(d.app.Open(shopLink), "the link in a wide window");
Build(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "opens its form there too, under the same question");
Check(!d.ui.Tap("nav.accounts") && !d.ui.Tap("pay.submit"), "which covers the places beside the form as well as the form");
TapBeside(d);
Equal(d.app.Screen(), std::string("pay"), "and is left by a tap beside it");
Press(d, "nav.accounts");
Press(d, "bar.refresh");
Equal(d.app.Screen(), std::string("accounts"), "the accounts read again do not bring it back");
Hides(d.ui, "A link asks for a payment", "and nothing waits");
Tap(d, "home.pay");
Shows(d.ui, "A link filled this in, not you.", "gone back to, the form is still said to be a link's");
Shows(d.ui, "Order 1234", "for as long as it holds what the link said");
Tap(d, "bar.back");
Tap(d, "home.pay");
Hides(d.ui, "A link filled this in", "which the way back empties it of");
Tap(d, "bar.back");
d.size = {0, 0, 400, 800};
Build(d);
}
// A link the app is started with is read before anything of the accounts is known: its form waits for them, and for
// which of them pay links start from, and the accounts' page says that it does.
void LinkWaiting(Fake::Bus& bus, sd_event* loop) {
{
Driver d(bus, loop);
d.app.Start();
Check(d.app.Open(shopLink), "a link is taken before the accounts are known");
Build(d);
Check(d.app.Busy() && d.app.Screen() == "accounts", "and waits for them, on the page they will be on");
Shows(d.ui, "A link asks for a payment.", "which says that it does");
Hides(d.ui, "Shop BV", "and nothing of what the link asks, which the form is for");
Settle(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "its form opens once they are known, asking which of them pays");
Shows(d.ui, "A link filled this in, not you.", "as a link's");
Shows(d.ui, "Order 1234", "filled in");
TapBeside(d);
Equal(d.app.Screen(), std::string("pay"), "a tap beside the question leaves the form");
Shows(d.ui, "Main", "paying from the account pay links start from");
Hides(d.ui, "Savings", "which is not the first one");
Tap(d, "bar.back");
Hides(d.ui, "A link asks for a payment", "and the accounts' page has no more to say of it");
}
{
// The accounts known, and which of them pay links start from not: that is read first.
Driver d(bus, loop);
d.app.Start();
Settle(d);
Check(d.app.Open(shopLink), "a link is taken once the accounts are known");
Build(d);
Check(d.app.Busy() && d.app.Screen() == "accounts", "and waits to hear which of them pay links start from");
Shows(d.ui, "A link asks for a payment.", "saying so above the accounts");
Shows(d.ui, "Savings", "which are listed meanwhile");
Settle(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "and then opens its form, with the question over it");
TapBeside(d);
Shows(d.ui, "Main", "which pays from that account when it is left as it is");
Hides(d.ui, "Savings", "and from no other");
}
{
// No system bus: the link waits until the accounts can be read, which is tried again by hand.
Driver d(bus, loop);
d.noBus = true;
d.app.Start();
Check(d.app.Open(shopLink), "a link is taken without a system bus");
Build(d);
Shows(d.ui, "The system bus cannot be reached", "which is said as ever");
Shows(d.ui, "A link asks for a payment.", "above the link that waits");
d.noBus = false;
Press(d, "overview.action");
Equal(d.app.Screen(), std::string("pay+accounts"), "a link whose accounts could not be read opens when they can be");
Shows(d.ui, "Order 1234", "as the link filled it in");
TapBeside(d);
Shows(d.ui, "Main", "from the account pay links start from, which is read with them");
Hides(d.ui, "Savings", "and not from the first");
}
{
// The user gone elsewhere while the accounts are read: what they are doing is not taken from them.
Driver d(bus, loop);
d.app.Start();
Check(d.app.Open(shopLink), "a link is taken");
Tap(d, "nav.cards");
Settle(d);
Equal(d.app.Screen(), std::string("cards"), "a user who went to another place meanwhile stays there");
Shows(d.ui, "The link's payment was not opened", "and is told that the link was not opened");
Tap(d, "nav.accounts");
Hides(d.ui, "A link asks for a payment", "the link is dropped");
Tap(d, "home.pay");
Hides(d.ui, "A link filled this in", "and nothing of it is in the pay form");
Hides(d.ui, "Order 1234", "which is empty");
}
{
// The user being told something when the accounts arrive: the form is not opened over that either.
Driver d(bus, loop);
d.app.Start();
Check(d.app.Open(shopLink) && d.app.Open("payto://iban/NL00MARK"), "a link that cannot be read, after one that waits");
Settle(d);
Equal(d.app.Screen(), std::string("accounts+link"), "is said to be one, and stays said");
Shows(d.ui, "This link cannot be opened", "by name");
Tap(d, "link.close");
Equal(d.app.Screen(), std::string("accounts"), "and the link that waited is not opened under it");
Tap(d, "home.pay");
Hides(d.ui, "Order 1234", "nor left in the pay form");
}
{
// The accounts known, and the system bus gone by the time the link comes: the reading of the account pay
// links start from fails at once, inside the call that opens the link. The form opens all the same, once.
Driver d(bus, loop);
d.app.Start();
Settle(d);
d.noBus = true;
bus.DisconnectOwn();
RunUntil(d.loop, [] { return false; }, std::chrono::seconds(1));
Check(d.app.Open(shopLink), "a link is taken with the accounts known and the system bus gone");
Build(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "and opens its form from the accounts as they were known");
Hides(d.ui, "The link's payment was not opened", "which is not said to be unopened over its own form");
TapBeside(d);
Shows(d.ui, "Order 1234", "and is filled in as the link has it");
}
{
// Another user of the machine, who chose no account for pay links to start from, and whose first connection
// pays between their own accounts only: the form starts from the first account that pays anybody, which is
// their second connection's.
{
std::lock_guard lock(bus.mutex);
bus.clientUid = erinUid;
bus.logindNames[erinUid] = "erin";
}
Client erin = Client::System();
erin.AddBunqOAuth("production", "fake-client", "fake-secret", "http://127.0.0.1/cb", "code-carol-erin");
erin.AddBunq(daveKey, "*", "");
Driver d(bus, loop);
d.app.Start();
Check(d.app.Open(shopLink), "a link for a user who chose no account to start from");
Settle(d);
Equal(d.app.Screen(), std::string("pay+accounts"), "opens its form under the choice of their accounts");
Check(Has(d, std::format("pick.{}", carolIban)) && Has(d, std::format("pick.{}", daveIban)), "both of them");
TapBeside(d);
Shows(d.ui, "Play money", "and starts from the first account that pays anybody");
Hides(d.ui, "Shared", "which is not their first account: that one's connection pays their own accounts only");
{
std::lock_guard lock(bus.mutex);
bus.clientUid = uid;
}
}
}
// An account that goes while the app is looking at it: nostrod no longer knows it, and the app looks again.
void Vanishing(Driver& d, Fake::Bus& bus, Fake::Bunq& bunq) {
Client other = Client::System();
@ -1648,7 +2013,7 @@ namespace {
Tap(d, "bar.back");
Tap(d, "nav.accounts");
Shows(d.ui, "No answer yet", "where it is said too");
// The settings while the account that pays at checkout cannot be read.
// The settings while the account pay links start from cannot be read.
SetPolkit(bus, Fake::Polkit::Deny, Bus::actionView);
Check(d.app.Navigate("settings"), "the settings");
Build(d);
@ -1857,6 +2222,7 @@ int main(int argc, char* argv[]) {
const std::uint64_t carol = bunq.AddPerson("Carol", "key-carol");
bunq.AddAccount(carol, carolIban, "Shared", 500);
bunq.AddGrant(carol, "code-carol", "token-carol");
bunq.AddGrant(carol, "code-carol-erin", "token-carol-erin");
const std::uint64_t dave = bunq.AddPerson("Dave", daveKey);
bunq.AddAccount(dave, daveIban, "Play money", 12345);
bunq.AddAccount(bunq.AddPerson("Alice", "key-alice-two"), otherAliceIban, "Other", 100);
@ -1877,11 +2243,13 @@ int main(int argc, char* argv[]) {
Cards(d, bus, bunq, alice);
Settings(d, bus, bunq);
OAuth(d, bus, bunq);
Linking(d, bus, bunq);
Vanishing(d, bus, bunq);
Sizes(d);
Routes(d);
Late(bus, loop);
Bare(bus, loop);
LinkWaiting(bus, loop);
Reconnecting(bus, loop);
Gone(d, bus, nostrod);
}