22 lines
1.0 KiB
C++
22 lines
1.0 KiB
C++
// Route: GET/POST /middleware/demo (builtin chain: headers, body limit, timing)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
using molo::example::fw::Method;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
Fixture f;
|
||
|
|
auto res = f.client->get("/middleware/demo");
|
||
|
|
check(res.status == 200, "status 200");
|
||
|
|
check(res.headers.get("X-Content-Type-Options") == "nosniff", "secure headers");
|
||
|
|
check(res.headers.get("X-Frame-Options") == "DENY", "frame options");
|
||
|
|
check(res.headers.has("X-Response-Time-Us"), "timing header");
|
||
|
|
auto small = f.client->request(Method::Post, "/middleware/demo", "tiny");
|
||
|
|
check(small.status == 200 && contains(small.body, "Received 4 body bytes"), "small body passes");
|
||
|
|
auto big = f.client->request(Method::Post, "/middleware/demo", std::string(65, 'x'));
|
||
|
|
check(big.status == 413, "body limit 413");
|
||
|
|
check(big.headers.get("X-Frame-Options") == "DENY", "outer middleware still runs on short circuit");
|
||
|
|
check(f.client->request(Method::Delete, "/middleware/demo").status == 405, "delete is 405");
|
||
|
|
return finish("middleware/demo");
|
||
|
|
}
|