Files

17 lines
796 B
C++
Raw Permalink Normal View History

// Route: GET /security/denials (capped ring of refusals)
#include "support/Assert.hpp"
using namespace molo::example::test;
static const char* kForm = "application/x-www-form-urlencoded";
int main() {
Fixture f;
check(contains(f.client->get("/security/denials").body, "\"total\":0"), "starts empty");
for (int i = 0; i < 120; ++i) f.client->post("/security/guard", "kind=x&value=a", kForm);
auto r = f.client->get("/security/denials");
check(r.status == 200 && contains(r.body, "\"total\":120"), "total counts all");
std::size_t n = 0, p = 0;
while ((p = r.body.find("\"guard\"", p)) != std::string::npos) { ++n; p += 7; }
check(n == 100, "ring capped at 100");
check(f.client->post("/security/denials", "x").status == 405, "POST 405");
return finish("security/denials");
}