44 lines
2.0 KiB
C++
44 lines
2.0 KiB
C++
// Route: GET /google/maps, /google/maps/status, /google/maps/calls (never call Google)
|
|
#include "support/GoogleRig.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
{
|
|
GoogleRig rig;
|
|
Fixture f(rig.client);
|
|
auto page = f.client->get("/google/maps");
|
|
check(page.status == 200, "page is 200");
|
|
check(contains(page.headers.get("Content-Type"), "text/html"), "page is html");
|
|
check(contains(page.body, "viewport") || contains(page.body, "Google Maps Platform"), "page renders");
|
|
check(contains(page.body, "/embedded/google_maps.js"), "page loads its script");
|
|
|
|
auto st = f.client->get("/google/maps/status");
|
|
check(st.status == 200, "status is 200");
|
|
check(contains(st.headers.get("Content-Type"), "application/json"), "status is json");
|
|
check(contains(st.body, "\"configured\":true"), "configured with a key");
|
|
check(contains(st.body, "\"max_points\":512"), "caps shown");
|
|
check(!contains(st.body, kTestKey), "credential never shown");
|
|
|
|
auto calls = f.client->get("/google/maps/calls");
|
|
check(calls.status == 200, "calls is 200");
|
|
check(contains(calls.body, "places.places.searchText"), "places search declared");
|
|
check(contains(calls.body, "\"source\":\"reference\""), "reference rows are marked");
|
|
check(contains(calls.body, "directions/v2:computeRoutes"), "routes declared");
|
|
check(!contains(calls.body, kTestKey), "no credential in the table");
|
|
|
|
check(f.client->post("/google/maps").status == 405, "page post is 405");
|
|
check(f.client->post("/google/maps/status").status == 405, "status post is 405");
|
|
check(f.client->post("/google/maps/calls").status == 405, "calls post is 405");
|
|
check(rig.mock->send_count() == 0, "side effect: no upstream traffic");
|
|
}
|
|
{
|
|
GoogleRig rig(false);
|
|
Fixture f(rig.client);
|
|
check(contains(f.client->get("/google/maps/status").body, "\"configured\":false"),
|
|
"not configured without a key");
|
|
check(f.client->get("/google/maps").status == 200, "page works without a credential");
|
|
}
|
|
return finish("google/maps/status");
|
|
}
|