24 lines
1.3 KiB
C++
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");
|
||
|
|
}
|