36 lines
1.6 KiB
C++
36 lines
1.6 KiB
C++
// Routes: GET /agent/sandbox, GET /agent/sandbox/status (2xx without a
|
|||
|
|
// credential, never any upstream traffic; POST is 405)
|
||
|
|
#include "support/GoogleRig.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
{
|
||
|
|
GoogleRig rig(false);
|
||
|
|
Fixture f(rig.client);
|
||
|
|
auto page = f.client->get("/agent/sandbox");
|
||
|
|
check(page.status == 200, "page 200 without a credential");
|
||
|
|
check(contains(page.headers.get("Content-Type"), "text/html"), "page is html");
|
||
|
|
check(contains(page.body, "Agent sandbox") && contains(page.body, "agent_sandbox.js"),
|
||
|
|
"page names the module and loads its script");
|
||
|
|
auto status = f.client->get("/agent/sandbox/status");
|
||
|
|
check(status.status == 200, "status 200 without a credential");
|
||
|
|
check(contains(status.headers.get("Content-Type"), "application/json"), "status is json");
|
||
|
|
check(contains(status.body, "\"configured\":false"), "not configured without a key");
|
||
|
|
check(contains(status.body, "\"max_command_bytes\":8192"), "caps are published");
|
||
|
|
check(rig.mock->send_count() == 0, "side effect: no upstream traffic");
|
||
|
|
}
|
||
|
|
{
|
||
|
|
GoogleRig rig;
|
||
|
|
Fixture f(rig.client);
|
||
|
|
auto status = f.client->get("/agent/sandbox/status");
|
||
|
|
check(contains(status.body, "\"configured\":true"), "configured with a key");
|
||
|
|
check(!contains(status.body, kTestKey), "credential never shown");
|
||
|
|
check(rig.mock->send_count() == 0, "status makes no upstream call");
|
||
|
|
}
|
||
|
|
Fixture f;
|
||
|
|
check(f.client->post("/agent/sandbox").status == 405, "post to the page is 405");
|
||
|
|
check(f.client->post("/agent/sandbox/status").status == 405, "post to status is 405");
|
||
|
|
return finish("agent/sandbox/page");
|
||
|
|
}
|