105 route tests, matrix crawl, spec and README updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
22 lines
1.0 KiB
C++
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");
|
|
}
|