This commit is contained in:
parent
320af54b3d
commit
4666c1995f
14 changed files with 876 additions and 346 deletions
|
|
@ -253,19 +253,43 @@ int main() {
|
|||
return validate("email=a%40b.example&name=Ada&street=x&postal=1&city=y&country="
|
||||
+ std::string(cc));
|
||||
};
|
||||
Check(withCountry("NL").Ok(), "checkout: the home market sells");
|
||||
Check(withCountry("CH").Ok() && withCountry("AU").Ok()
|
||||
&& withCountry("HK").Ok() && withCountry("SG").Ok()
|
||||
&& withCountry("RS").Ok() && withCountry("ME").Ok()
|
||||
&& withCountry("AL").Ok() && withCountry("XK").Ok()
|
||||
&& withCountry("GE").Ok(),
|
||||
"checkout: every cleared destination sells");
|
||||
Check(!withCountry("JP").Ok() && !withCountry("NZ").Ok(),
|
||||
"checkout: destinations refuted on verification stay refused");
|
||||
// The default is the point of an allow-list: uncleared, unknown and
|
||||
// never-considered codes all refuse without anyone listing them.
|
||||
Check(!withCountry("US").Ok(), "checkout: US refused");
|
||||
Check(!withCountry("CA").Ok(), "checkout: CA refused");
|
||||
Check(!withCountry("us").Ok(), "checkout: lowercase US refused too");
|
||||
Check(withCountry("GB").Ok(), "checkout: other non-EU destinations still sell");
|
||||
Check(withCountry("NL").Ok(), "checkout: EU unaffected");
|
||||
Check(!withCountry("DE").Ok() && !withCountry("GB").Ok()
|
||||
&& !withCountry("NO").Ok() && !withCountry("TR").Ok(),
|
||||
"checkout: uncleared destinations refuse");
|
||||
Check(!withCountry("XX").Ok(),
|
||||
"checkout: a syntactically valid code nobody has cleared refuses");
|
||||
{
|
||||
auto us = withCountry("US");
|
||||
Check(us.errors.size() == 1 && us.errors[0].field == "country",
|
||||
"checkout: refusal is a country error, nothing else");
|
||||
Check(us.errors[0].message == Catcrafts::Form::kNoSaleMessage,
|
||||
"checkout: refusal says where the shop does not sell");
|
||||
Check(us.errors[0].message == Catcrafts::Form::kRegulatoryMessage,
|
||||
"checkout: refusal gives the regulatory reason");
|
||||
Check(us.value.country == "US", "checkout: refused country echoed back");
|
||||
}
|
||||
{
|
||||
// One sentence for every non-sanctions refusal, whatever the underlying
|
||||
// reason was — the buyer cannot act on the difference.
|
||||
auto de = withCountry("DE");
|
||||
auto tr = withCountry("TR");
|
||||
Check(de.errors.size() == 1 && tr.errors.size() == 1
|
||||
&& de.errors[0].message == Catcrafts::Form::kRegulatoryMessage
|
||||
&& tr.errors[0].message == Catcrafts::Form::kRegulatoryMessage,
|
||||
"checkout: every uncleared destination gets the same sentence");
|
||||
}
|
||||
|
||||
// Sanctioned destinations: same gate, different sentence. The message has
|
||||
// to name the law rather than shop policy — a buyer told "Catcrafts does
|
||||
|
|
@ -284,6 +308,11 @@ int main() {
|
|||
Check(ru.value.country == "RU", "checkout: sanctioned country echoed back");
|
||||
}
|
||||
|
||||
// Sanctions keep their own sentence: a buyer told the generic "email us and
|
||||
// ask" would waste their time on something no amount of paperwork can lift.
|
||||
Check(withCountry("RU").errors[0].message != Catcrafts::Form::kRegulatoryMessage,
|
||||
"checkout: sanctions do not collapse into the regulatory sentence");
|
||||
|
||||
// Parameter pollution against the order gate. Every refusal above reads its
|
||||
// field through Fields::Get, which takes the FIRST of a repeated pair, so
|
||||
// appending a second value cannot reopen a destination the first one closed
|
||||
|
|
|
|||
Loading…
Reference in a new issue