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
+21
View File
@@ -0,0 +1,21 @@
// Route: GET/POST /governance/diff (breaking change detection)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
check(f.client->get("/governance/diff").status == 200, "form");
auto bad = f.client->post("/governance/diff", "before=GET+%2Fa", "application/x-www-form-urlencoded");
check(bad.status == 422 && contains(bad.body, "field-error"), "after required");
std::string before = "GET /items required=id\nDELETE /items required=id\n";
std::string after = "GET /items required=id,page\nPOST /items required=name\n";
auto r = f.client->request(Method::Post, "/governance/diff", "before=" + before + "&after=" + after, {{"Accept", "application/json"}});
check(r.status == 200 && contains(r.body, "\"breaking\":2"), "two breaking changes");
check(contains(r.body, "operation removed") && contains(r.body, "new required parameter page"), "details");
check(contains(r.body, "operation added"), "compatible addition");
auto same = f.client->request(Method::Post, "/governance/diff", "before=GET /a&after=GET /a", {{"Accept", "application/json"}});
check(contains(same.body, "\"breaking\":0"), "side effect: identical specs clean");
return finish("governance/diff");
}
+27
View File
@@ -0,0 +1,27 @@
// Route: GET/POST /governance/keys (+ revoke, whoami): API keys with scopes
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
check(f.client->get("/governance/keys").status == 200, "form page");
auto bad = f.client->post("/governance/keys", "owner=&tier=gold", "application/x-www-form-urlencoded");
check(bad.status == 422 && contains(bad.body, "field-error"), "inline errors");
auto js = f.client->request(Method::Post, "/governance/keys", "owner=ada&tier=free&scopes=read", {{"Accept", "application/json"}});
check(js.status == 201 && contains(js.body, "mk_"), "issued");
std::string key = js.body.substr(js.body.find("mk_"), 35);
auto who = f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
check(who.status == 200 && contains(who.body, "ada"), "authenticates");
check(f.client->get("/governance/whoami").status == 401, "missing key 401");
check(f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", "mk_bogus"}}).status == 401, "unknown 401");
auto nos = f.client->request(Method::Post, "/governance/keys", "owner=bob&scopes=write", {{"Accept", "application/json"}});
std::string k2 = nos.body.substr(nos.body.find("mk_"), 35);
check(f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", k2}}).status == 403, "missing scope 403");
check(f.client->post("/governance/keys/key1/revoke").status == 200, "revoke");
auto rev = f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
check(rev.status == 401 && contains(rev.body, "Revoked"), "side effect: revoked key rejected");
check(f.client->post("/governance/keys/nope/revoke").status == 404, "unknown revoke 404");
return finish("governance/keys");
}
+20
View File
@@ -0,0 +1,20 @@
// Route: GET/POST /governance/lint (route linter, HTML form)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
check(f.client->get("/governance/lint").status == 200, "form");
auto bad = f.client->post("/governance/lint", "paths=", "application/x-www-form-urlencoded");
check(bad.status == 422 && contains(bad.body, "field-error") && !contains(bad.body, "\"failures\""), "inline error");
auto ok = f.client->post("/governance/lint", "paths=%2Fusers%2F%0A%2FgetUser%0A%2Fuser_list%0A%2Fusers", "application/x-www-form-urlencoded");
check(ok.status == 200 && contains(ok.body, "no-trailing-slash"), "trailing slash found");
check(contains(ok.body, "lowercase-only") && contains(ok.body, "kebab-case"), "other rules");
auto clean = f.client->request(Method::Post, "/governance/lint", "paths=/users\n/orders", {{"Accept", "application/json"}});
check(contains(clean.body, "\"findings\":[]"), "clean paths: no findings (json)");
auto verbs = f.client->request(Method::Post, "/governance/lint", "paths=/api/get/users", {{"Accept", "application/json"}});
check(contains(verbs.body, "no-verbs-in-path"), "side effect: verb rule");
return finish("governance/lint");
}
+18
View File
@@ -0,0 +1,18 @@
// Route: GET /governance/problem[/:status] (RFC 7807)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
check(f.client->get("/governance/problem").status == 200, "overview");
auto p = f.client->get("/governance/problem/404");
check(p.status == 404 && contains(p.headers.get("Content-Type"), "application/problem+json"), "problem content type");
check(contains(p.body, "\"status\":404") && contains(p.body, "\"title\"") && contains(p.body, "\"instance\""), "rfc7807 members");
auto bad = f.client->get("/governance/problem/200");
check(bad.status == 400 && contains(bad.headers.get("Content-Type"), "problem+json"), "out of range is 400");
check(f.client->get("/governance/problem/abc").status == 400, "non numeric");
check(f.client->post("/governance/problem/404").status == 405, "405");
return finish("governance/problem");
}
+23
View File
@@ -0,0 +1,23 @@
// Route: GET /governance/tiers (+ whoami rate-limit headers)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
auto t = f.client->get("/governance/tiers");
check(t.status == 200 && contains(t.body, "\"per_min\":3") && contains(t.body, "\"per_min\":10"), "tiers");
auto js = f.client->request(Method::Post, "/governance/keys", "owner=ada&tier=free&scopes=read", {{"Accept", "application/json"}});
std::string key = js.body.substr(js.body.find("mk_"), 35);
auto r1 = f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
check(r1.headers.get("X-RateLimit-Limit") == "3" && r1.headers.get("X-RateLimit-Remaining") == "2", "headers");
check(r1.headers.get("X-Tier") == "free", "tier header");
f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
auto r4 = f.client->request(Method::Get, "/governance/whoami", "", {{"X-API-Key", key}});
check(r4.status == 429 && r4.headers.get("Retry-After") == "60", "limit 429 with Retry-After");
check(contains(r4.headers.get("Content-Type"), "problem+json"), "problem body");
check(r4.headers.get("X-RateLimit-Remaining") == "0", "side effect: ledger exhausted");
return finish("governance/tiers");
}
@@ -0,0 +1,15 @@
// Route: GET /governance/versions (version table)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
auto r = f.client->get("/governance/versions");
check(r.status == 200 && contains(r.body, "\"deprecated\":true") && contains(r.body, "\"deprecated\":false"), "table");
check(contains(r.body, "GMT"), "sunset date listed");
check(f.client->post("/governance/versions").status == 405, "405");
check(contains(r.headers.get("Content-Type"), "application/json"), "json");
return finish("governance/versions");
}