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>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Route: GET /security/rate (5 hits per 60 s per client, then 429)
|
||||
#include "support/Assert.hpp"
|
||||
using namespace molo::example::test;
|
||||
using molo::example::fw::Method;
|
||||
int main() {
|
||||
Fixture f;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
auto r = f.client->request(Method::Get, "/security/rate", "", {{"X-Client-Id", "a"}});
|
||||
check(r.status == 200, "hit " + std::to_string(i + 1) + " allowed");
|
||||
if (i == 4) check(contains(r.body, "\"remaining\":0"), "remaining reaches 0");
|
||||
}
|
||||
auto limited = f.client->request(Method::Get, "/security/rate", "", {{"X-Client-Id", "a"}});
|
||||
check(limited.status == 429, "6th hit is 429");
|
||||
int retry = std::atoi(limited.headers.get("Retry-After").c_str());
|
||||
check(retry >= 1 && retry <= 61, "Retry-After within window");
|
||||
auto other = f.client->request(Method::Get, "/security/rate", "", {{"X-Client-Id", "b"}});
|
||||
check(other.status == 200, "other client unaffected");
|
||||
check(f.client->post("/security/rate", "x").status == 405, "POST is 405");
|
||||
check(contains(f.client->get("/security/denials").body, "RateLimiter"), "side effect: denial recorded");
|
||||
return finish("security/rate");
|
||||
}
|
||||
Reference in New Issue
Block a user