31 lines
1.8 KiB
C++
31 lines
1.8 KiB
C++
// Routes: GET /google/data/status and /google/data/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 res = f.client->get("/google/data/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");
|
||
|
|
for (const char* api : {"bigquery", "storage", "pubsub", "firestore", "spanner", "bigtableadmin",
|
||
|
|
"secretmanager", "dataplex", "dlp", "cloudkms", "datastore"})
|
||
|
|
check(contains(res.body, std::string("\"name\":\"") + api + "\""), std::string("lists ") + api);
|
||
|
|
check(contains(res.body, "\"service\":\"bigquery.googleapis.com\""), "shows the service to enable");
|
||
|
|
check(contains(res.body, "\"max_signed_url_seconds\":604800"), "signed URL cap shown");
|
||
|
|
auto all = f.client->get("/google/data/calls?api=pubsub");
|
||
|
|
check(all.status == 200 && contains(all.body, "pubsub.projects.topics.publish"), "table lists publish");
|
||
|
|
check(!contains(all.body, "bigquery.jobs.query"), "api filter applies");
|
||
|
|
check(contains(f.client->get("/google/data/calls?api=storage").body, "storage.objects.compose"), "table lists compose");
|
||
|
|
GoogleRig on;
|
||
|
|
Fixture g(on.client);
|
||
|
|
check(contains(g.client->get("/google/data/status").body, "\"configured\":true"), "reports credential");
|
||
|
|
check(f.client->post("/google/data/status", "{}", "application/json").status == 405, "post is 405");
|
||
|
|
check(f.client->post("/google/data/calls", "{}", "application/json").status == 405, "calls post is 405");
|
||
|
|
check(on.mock->send_count() == 0, "no network");
|
||
|
|
return finish("google/data/status");
|
||
|
|
}
|