Files
moloapp/tests/example/tenancy/quota_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

22 lines
1.0 KiB
C++

// Route: GET/POST /tenancy/quota (plan quotas)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
Method P = Method::Post;
check(f.client->get("/tenancy/quota").status == 200, "get");
int s = 0;
for (int i = 0; i < 3; ++i) s = f.client->request(P, "/tenancy/quota", "", {{"X-Tenant-ID", "globex"}}).status;
check(s == 200, "free plan allows 3");
auto over = f.client->request(P, "/tenancy/quota", "", {{"X-Tenant-ID", "globex"}});
check(over.status == 429 && over.headers.get("Retry-After") == "60", "4th is 429 with Retry-After");
auto pro = f.client->request(P, "/tenancy/quota", "", {{"X-Tenant-ID", "acme"}});
check(pro.status == 200 && contains(pro.body, "\"limit\":10"), "pro has bigger limit");
check(contains(f.client->get("/tenancy/metrics").body, "quota.denied"), "side effect: denied metric");
check(f.client->request(P, "/tenancy/quota", "", {{"X-Tenant-ID", "ghost"}}).status == 404, "unknown tenant");
return finish("tenancy/quota");
}