This commit is contained in:
parent
eb655b24b6
commit
25805a093a
20 changed files with 788 additions and 805 deletions
|
|
@ -11,21 +11,28 @@ No permission is granted to copy, modify, distribute, or create derivative works
|
|||
// backend exists: a client-side router cannot produce one.
|
||||
|
||||
import std;
|
||||
import Catcrafts.Shared;
|
||||
import Catcrafts.E2eHarness;
|
||||
|
||||
using namespace Catcrafts;
|
||||
using namespace Catcrafts::E2e;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
TestServer srv(argv[1], 8210);
|
||||
|
||||
// ── status codes ──────────────────────────────────────────────────
|
||||
for (std::string_view p : { "/", "/about", "/shop", "/shop/fp6-pmos",
|
||||
"/shop/fp6plus-pmos", "/shop/donation", "/projects",
|
||||
for (std::string_view p : { "/", "/about", "/shop", "/shop/donation", "/projects",
|
||||
"/posts", "/demos", "/demos/raytracer", "/financials",
|
||||
"/legal/privacy", "/legal/terms", "/legal/imprint",
|
||||
"/feed.xml", "/sitemap.xml", "/api/healthz" }) {
|
||||
srv.CheckStatus(std::string(p), "200");
|
||||
}
|
||||
// Every catalogue entry has a page, whatever its status: a coming-soon or
|
||||
// withdrawn listing stays up with its form closed, and only a slug the
|
||||
// catalogue never held is a 404.
|
||||
for (const Product& pr : Content::Products()) {
|
||||
srv.CheckStatus("/shop/" + pr.slug, "200");
|
||||
}
|
||||
// Trailing slashes must normalise, not 404 or duplicate the canonical URL.
|
||||
srv.CheckStatus("/projects/", "200");
|
||||
srv.CheckStatus("/shop/", "200");
|
||||
|
|
@ -72,9 +79,11 @@ int main(int argc, char** argv) {
|
|||
srv.HeaderHas("/sitemap.xml", "content-type", "application/xml", "sitemap content-type");
|
||||
|
||||
// ── sitemap and feed content ──────────────────────────────────────
|
||||
srv.BodyHas("/sitemap.xml", "/shop/fp6-pmos", "sitemap lists the product");
|
||||
srv.BodyHas("/sitemap.xml", "/shop/fp6plus-pmos",
|
||||
"sitemap lists the refresh — it comes off the catalogue, not a second list");
|
||||
// Product URLs come off the catalogue, not a second list, so every entry
|
||||
// is advertised and nothing that is not listed can be.
|
||||
for (const Product& pr : Content::Products()) {
|
||||
srv.BodyHas("/sitemap.xml", "/shop/" + pr.slug, "sitemap lists " + pr.slug);
|
||||
}
|
||||
srv.BodyHas("/sitemap.xml", "/about", "sitemap lists the about page");
|
||||
srv.BodyHas("/sitemap.xml", "/legal/privacy", "sitemap lists the privacy page");
|
||||
srv.BodyHas("/sitemap.xml", "/demos", "sitemap lists the demos page");
|
||||
|
|
@ -84,11 +93,13 @@ int main(int argc, char** argv) {
|
|||
srv.BodyHas("/feed.xml", "<feed xmlns=\"http://www.w3.org/2005/Atom\">", "feed is Atom");
|
||||
|
||||
// ── abuse ─────────────────────────────────────────────────────────
|
||||
srv.CheckStatus("/shop/fp6-pmos", "413", "POST",
|
||||
// The body guards run for any listed product before its form is read, so
|
||||
// the donation item (the one entry every catalogue has) is the target.
|
||||
srv.CheckStatus("/shop/donation", "413", "POST",
|
||||
"email=a%40b.example&name=" + std::string(20000, 'x')
|
||||
+ "&street=x&postal=1&city=y&country=NL");
|
||||
{
|
||||
const auto json = srv.Post("/shop/fp6-pmos", "{}", "application/json");
|
||||
const auto json = srv.Post("/shop/donation", "{}", "application/json");
|
||||
Check(json.status == "415", "POST with a JSON content-type -> 415", json.status);
|
||||
}
|
||||
srv.CheckStatus("/shop/nope", "404", "POST",
|
||||
|
|
|
|||
Loading…
Reference in a new issue