// Routes: POST /agent/registry/operations/list, POST /agent/registry/operations/cancel, // DELETE /agent/registry/operations (explicit destructive route) #include "agent/registry/cases.hpp" using namespace molo::example::test; using molo::example::fw::Method; int main() { for (const char* scope : {"registry", "gateways", "policies"}) { std::string s = scope; check_google_post_route("/agent/registry/operations/list", "{\"scope\":\"" + s + "\"}", "{\"scope\":\"nowhere\"}", "unknown scope"); check_google_post_route("/agent/registry/operations/cancel", "{\"scope\":\"" + s + "\",\"id\":\"op-1\"}", "{\"scope\":\"" + s + "\",\"id\":\"a/b\"}", "bad operation id"); } { GoogleRig rig(false); Fixture f(rig.client); auto del = f.client->request(Method::Delete, "/agent/registry/operations?scope=gateways&id=op-1"); check(del.status == 503 && contains(del.body, "google_not_configured"), "delete operation: 503 without a credential"); check(rig.mock->send_count() == 0, "side effect: no upstream traffic"); } { GoogleRig rig; Fixture f(rig.client); check(f.client->request(Method::Delete, "/agent/registry/operations?scope=x&id=op-1").status == 422, "delete: unknown scope is 422"); check(f.client->request(Method::Delete, "/agent/registry/operations?scope=policies&id=a..b").status == 422, "delete: bad id is 422"); check(f.client->request(Method::Delete, "/agent/registry/operations").status == 422, "delete: missing parameters are 422"); check(f.client->get("/agent/registry/operations").status == 405, "get never deletes"); check(f.client->post("/agent/registry/operations").status == 405, "post never deletes"); check(rig.mock->send_count() == 0, "side effect: rejected before any upstream call"); } return finish("agent/registry/operations"); }