105 route tests, matrix crawl, spec and README updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
1.5 KiB
C++
28 lines
1.5 KiB
C++
// Route: /clients/session (cookie jar, pool, proxy, auth)
|
|
#include "support/Assert.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
using molo::example::fw::Method;
|
|
|
|
static const char* kForm = "application/x-www-form-urlencoded";
|
|
|
|
int main() {
|
|
Fixture f;
|
|
check(f.client->get("/clients/session").status == 200, "status 200");
|
|
auto r1 = f.client->post("/clients/session/request", "auth=basic", kForm);
|
|
check(contains(r1.body, "Authorization=Basic ZGVtbzpkZW1v"), "basic auth header");
|
|
check(!contains(r1.body, "Cookie="), "first request has no cookie");
|
|
auto r2 = f.client->post("/clients/session/request", "auth=bearer", kForm);
|
|
check(contains(r2.body, "Cookie=sid=s-1; visits=1"), "cookie jar replays server cookies");
|
|
check(contains(r2.body, "Bearer demo-token"), "bearer header");
|
|
check(contains(r2.body, "connection reused"), "pooled connection reused");
|
|
auto r3 = f.client->post("/clients/session/request", "proxy=http://proxy.local:3128", kForm);
|
|
check(contains(r3.body, "connection created via http://proxy.local:3128"), "proxy change opens new connection");
|
|
auto bad = f.client->post("/clients/session/request", "proxy=ftp://x", kForm);
|
|
check(bad.status == 422 && contains(bad.body, "socks5://host:port"), "422 bad proxy");
|
|
auto badauth = f.client->post("/clients/session/request", "auth=digest", kForm);
|
|
check(badauth.status == 422, "422 unknown auth");
|
|
check(contains(f.client->get("/clients/session").body, "pool_created"), "side effect: pool stats shown");
|
|
return finish("clients/session");
|
|
}
|