19 lines
915 B
C++
19 lines
915 B
C++
// Route: GET /audit/verify + POST /audit/tamper (tamper detection)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto v = f.client->get("/audit/verify");
|
||
|
|
check(v.status == 200 && contains(v.body, "\"intact\":true") && contains(v.body, "\"first_broken\":null"), "intact");
|
||
|
|
check(f.client->post("/audit/tamper", "index=abc").status == 422, "bad index");
|
||
|
|
check(f.client->post("/audit/tamper", "index=99").status == 404, "missing record");
|
||
|
|
check(f.client->post("/audit/tamper", "index=1").status == 200, "tamper");
|
||
|
|
auto b = f.client->get("/audit/verify");
|
||
|
|
check(contains(b.body, "\"intact\":false") && contains(b.body, "\"first_broken\":1"), "first broken index reported");
|
||
|
|
check(contains(f.client->get("/audit/log").body, "Chain broken at index 1"), "side effect: page shows break");
|
||
|
|
return finish("audit/verify");
|
||
|
|
}
|