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,19 @@
|
||||
// Route: GET /security/admin (Bearer token, role permission check)
|
||||
#include "support/Assert.hpp"
|
||||
using namespace molo::example::test;
|
||||
using molo::example::fw::Method;
|
||||
int main() {
|
||||
Fixture f;
|
||||
check(contains(f.client->get("/security/roles").body, "admin:manage"), "roles page lists permissions");
|
||||
auto none = f.client->get("/security/admin");
|
||||
check(none.status == 401 && none.headers.get("WWW-Authenticate") == "Bearer", "no token 401");
|
||||
auto junk = f.client->request(Method::Get, "/security/admin", "", {{"Authorization", "Bearer nope"}});
|
||||
check(junk.status == 401, "unknown token 401");
|
||||
auto viewer = f.client->request(Method::Get, "/security/admin", "", {{"Authorization", "Bearer viewer-token"}});
|
||||
check(viewer.status == 403 && contains(viewer.body, "viewer"), "viewer 403");
|
||||
auto admin = f.client->request(Method::Get, "/security/admin", "", {{"Authorization", "Bearer admin-token"}});
|
||||
check(admin.status == 200 && contains(admin.body, "\"role\":\"admin\""), "admin 200");
|
||||
check(f.client->post("/security/admin", "x").status == 405, "POST 405");
|
||||
check(contains(f.client->get("/security/denials").body, "lacks admin:manage"), "side effect: denial recorded");
|
||||
return finish("security/admin");
|
||||
}
|
||||
Reference in New Issue
Block a user