21 lines
1.2 KiB
C++
21 lines
1.2 KiB
C++
// Route: GET/POST /governance/lint (route linter, HTML form)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
check(f.client->get("/governance/lint").status == 200, "form");
|
||
|
|
auto bad = f.client->post("/governance/lint", "paths=", "application/x-www-form-urlencoded");
|
||
|
|
check(bad.status == 422 && contains(bad.body, "field-error") && !contains(bad.body, "\"failures\""), "inline error");
|
||
|
|
auto ok = f.client->post("/governance/lint", "paths=%2Fusers%2F%0A%2FgetUser%0A%2Fuser_list%0A%2Fusers", "application/x-www-form-urlencoded");
|
||
|
|
check(ok.status == 200 && contains(ok.body, "no-trailing-slash"), "trailing slash found");
|
||
|
|
check(contains(ok.body, "lowercase-only") && contains(ok.body, "kebab-case"), "other rules");
|
||
|
|
auto clean = f.client->request(Method::Post, "/governance/lint", "paths=/users\n/orders", {{"Accept", "application/json"}});
|
||
|
|
check(contains(clean.body, "\"findings\":[]"), "clean paths: no findings (json)");
|
||
|
|
auto verbs = f.client->request(Method::Post, "/governance/lint", "paths=/api/get/users", {{"Accept", "application/json"}});
|
||
|
|
check(contains(verbs.body, "no-verbs-in-path"), "side effect: verb rule");
|
||
|
|
return finish("governance/lint");
|
||
|
|
}
|