105 route tests, matrix crawl, spec and README updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
22 lines
1.2 KiB
C++
22 lines
1.2 KiB
C++
// Route: GET/POST /audit/log (hash-chained log page and append form)
|
|
#include "support/Assert.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
using molo::example::fw::Method;
|
|
|
|
int main() {
|
|
Fixture f;
|
|
auto page = f.client->get("/audit/log");
|
|
check(page.status == 200 && contains(page.headers.get("Content-Type"), "text/html"), "html page");
|
|
check(contains(page.body, "Chain intact"), "intact");
|
|
auto js = f.client->request(Method::Get, "/audit/log", "", {{"Accept", "application/json"}});
|
|
check(contains(js.body, "\"records\""), "json variant");
|
|
auto bad = f.client->post("/audit/log", "actor=&action=x&subject=y", "application/x-www-form-urlencoded");
|
|
check(bad.status == 422 && contains(bad.body, "field-error"), "inline validation");
|
|
auto ok = f.client->post("/audit/log", "actor=ada&action=edit&subject=doc&detail=mail+me%40example.com", "application/x-www-form-urlencoded");
|
|
check(ok.status == 201 && contains(ok.body, "appended"), "appended");
|
|
auto after = f.client->request(Method::Get, "/audit/log", "", {{"Accept", "application/json"}});
|
|
check(contains(after.body, "[EMAIL]") && !contains(after.body, "me@example.com"), "side effect: PII redacted in record");
|
|
return finish("audit/log");
|
|
}
|