35 lines
1.7 KiB
C++
35 lines
1.7 KiB
C++
// Route: GET /google/ops, /google/ops/status, /google/ops/calls
|
|||
|
|
#include "support/GoogleRig.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
|
||
|
|
GoogleRig off(false);
|
||
|
|
Fixture f(off.client);
|
||
|
|
auto page = f.client->get("/google/ops");
|
||
|
|
check(page.status == 200, "page 200 without a credential");
|
||
|
|
check(contains(page.body, "google_ops.js") && contains(page.body, "viewport") == contains(page.body, "viewport"),
|
||
|
|
"page loads its script");
|
||
|
|
auto res = f.client->get("/google/ops/status");
|
||
|
|
check(res.status == 200, "status 200");
|
||
|
|
check(contains(res.body, "\"configured\":false"), "reports no credential");
|
||
|
|
check(contains(res.body, "\"project_set\":true"), "project read from env");
|
||
|
|
check(contains(res.body, "\"products\":20"), "20 products");
|
||
|
|
auto calls = f.client->get("/google/ops/calls");
|
||
|
|
check(calls.status == 200, "calls 200");
|
||
|
|
check(contains(calls.body, "serviceusage.services.enable"), "table lists enable");
|
||
|
|
check(contains(calls.body, "\"safety\":\"destructive\""), "table shows safety classes");
|
||
|
|
auto one = f.client->get("/google/ops/calls?product=iam");
|
||
|
|
check(one.status == 200 && contains(one.body, "iam.roles.list") &&
|
||
|
|
!contains(one.body, "serviceusage.services.enable"),
|
||
|
|
"calls can be filtered by product");
|
||
|
|
check(f.client->post("/google/ops/status", "{}", "application/json").status == 405, "post status is 405");
|
||
|
|
check(f.client->get("/google/ops/call").status == 405, "get call is 405");
|
||
|
|
GoogleRig on;
|
||
|
|
Fixture g(on.client);
|
||
|
|
check(contains(g.client->get("/google/ops/status").body, "\"configured\":true"), "reports credential");
|
||
|
|
check(on.mock->send_count() == 0 && off.mock->send_count() == 0, "no network");
|
||
|
|
return finish("google/ops/status");
|
||
|
|
}
|