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,22 @@
|
||||
// Route: OPTIONS /security/cors (origin allowlist preflight)
|
||||
#include "support/Assert.hpp"
|
||||
using namespace molo::example::test;
|
||||
using molo::example::fw::Method;
|
||||
int main() {
|
||||
Fixture f;
|
||||
check(f.client->get("/security/cors").status == 200, "info page 200");
|
||||
auto ok = f.client->request(Method::Options, "/security/cors", "",
|
||||
{{"Origin", "https://app.example.com"}});
|
||||
check(ok.status == 204, "allowed origin is 204");
|
||||
check(ok.headers.get("Access-Control-Allow-Origin") == "https://app.example.com", "origin echoed");
|
||||
check(ok.headers.has("Access-Control-Allow-Methods"), "methods header");
|
||||
auto bad = f.client->request(Method::Options, "/security/cors", "", {{"Origin", "https://evil.example"}});
|
||||
check(bad.status == 403, "unknown origin is 403");
|
||||
check(!bad.headers.has("Access-Control-Allow-Origin"), "no allow header on denial");
|
||||
auto none = f.client->request(Method::Options, "/security/cors");
|
||||
check(none.status == 403, "missing origin is 403");
|
||||
auto post = f.client->post("/security/cors", "x");
|
||||
check(post.status == 405, "POST is 405");
|
||||
check(contains(f.client->get("/security/denials").body, "CorsPolicy"), "side effect: denial recorded");
|
||||
return finish("security/cors");
|
||||
}
|
||||
Reference in New Issue
Block a user