feat(workflow): example covers security, platform, enterprise and resilience features

105 route tests, matrix crawl, spec and README updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 02:19:52 +02:00
co-authored by Claude Sonnet 5.5
parent 00af65613d
commit 62fdd08da8
90 changed files with 8038 additions and 11 deletions
+24
View File
@@ -0,0 +1,24 @@
// Route: GET /csp/page (per-request nonce in header and script tag)
#include "support/Assert.hpp"
using namespace molo::example::test;
static std::string nonce_of(const std::string& h) {
std::size_t a = h.find("'nonce-");
if (a == std::string::npos) return "";
a += 7;
return h.substr(a, h.find('\'', a) - a);
}
int main() {
Fixture f;
auto a = f.client->get("/csp/page");
auto b = f.client->get("/csp/page");
check(a.status == 200 && contains(a.content_type(), "text/html"), "html 200");
std::string h = a.headers.get("Content-Security-Policy-Report-Only");
check(contains(h, "default-src 'none'"), "deny-first default");
check(contains(h, "report-uri /csp/report"), "report uri set");
std::string n = nonce_of(h);
check(n.size() == 32, "nonce is 16 random bytes in hex");
check(contains(a.body, "<script nonce=\"" + n + "\">"), "script carries same nonce");
check(n != nonce_of(b.headers.get("Content-Security-Policy-Report-Only")), "nonce differs per request");
check(f.client->post("/csp/page", "x").status == 405, "POST is 405");
return finish("csp/page");
}
+19
View File
@@ -0,0 +1,19 @@
// Route: /csp/report (violation report intake, capped store)
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
auto ok = f.client->post("/csp/report", "{\"csp-report\":{\"blocked-uri\":\"inline\"}}", "application/csp-report");
check(ok.status == 204, "report accepted 204");
auto empty = f.client->post("/csp/report", "", "application/csp-report");
check(empty.status == 400, "empty report is 400");
auto big = f.client->post("/csp/report", std::string(5000, 'x'), "application/csp-report");
check(big.status == 400, "oversized report is 400");
for (int i = 0; i < 60; ++i) f.client->post("/csp/report", "r", "application/csp-report");
auto list = f.client->get("/csp/report");
check(list.status == 200 && contains(list.body, "\"total\":61"), "total counted");
std::size_t n = 0, p = 0;
while ((p = list.body.find("\"r\"", p)) != std::string::npos) { ++n; p += 3; }
check(n <= 50, "stored reports capped at 50");
return finish("csp/report");
}