Files
moloapp/tests/example/audit/retention_test.cpp
T
retoorandClaude Sonnet 5.5 62fdd08da8 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>
2026-10-24 02:19:52 +02:00

24 lines
1.3 KiB
C++

// Route: GET /audit/retention + hold + purge (policy, legal hold, dry run)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
auto page = f.client->get("/audit/retention");
check(page.status == 200 && contains(page.body, "expired"), "html page");
auto js = f.client->request(Method::Get, "/audit/retention", "", {{"Accept", "application/json"}});
check(contains(js.body, "\"r1\"") && contains(js.body, "\"r5\""), "expired listed");
auto dry = f.client->post("/audit/retention/purge", "");
check(contains(dry.body, "\"dry_run\":true") && contains(dry.body, "\"purged\":0"), "dry run by default");
check(f.client->post("/audit/retention/hold", "id=r1&hold=true").status == 200, "hold");
auto real = f.client->post("/audit/retention/purge", "confirm=yes");
check(contains(real.body, "\"purged\":2"), "held entry skipped, two purged");
auto after = f.client->request(Method::Get, "/audit/retention", "", {{"Accept", "application/json"}});
check(contains(after.body, "\"r1\"") && !contains(after.body, "\"id\":\"r5\""), "side effect: r1 kept, r5 gone");
check(f.client->post("/audit/retention/hold", "id=r1&hold=x").status == 422, "bad hold");
check(f.client->post("/audit/retention/hold", "id=zz&hold=true").status == 404, "unknown id");
return finish("audit/retention");
}