31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
// Route: POST /agent/optimize/logs (Cloud Logging entries:list)
|
|||
|
|
#include <cstdlib>
|
||
|
|
|
||
|
|
#include "support/GoogleRig.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
setenv("GOOGLE_CLOUD_PROJECT", "test-proj", 1);
|
||
|
|
const char* json = "application/json";
|
||
|
|
GoogleRig keyed;
|
||
|
|
Fixture f(keyed.client);
|
||
|
|
check(f.client->post("/agent/optimize/logs", "{\"limit\":101}", json).status == 422,
|
||
|
|
"limit over 100 is 422");
|
||
|
|
check(f.client->post("/agent/optimize/logs",
|
||
|
|
"{\"filter\":\"" + std::string(2001, 'x') + "\"}", json).status == 422,
|
||
|
|
"filter over 2000 characters is 422");
|
||
|
|
check(f.client->post("/agent/optimize/logs", "{\"trace_id\":\"not-hex\"}", json).status == 422,
|
||
|
|
"malformed trace id is 422");
|
||
|
|
check(keyed.mock->send_count() == 0, "rejected input never reached Google");
|
||
|
|
check(f.client->get("/agent/optimize/logs").status == 405, "get is 405");
|
||
|
|
|
||
|
|
GoogleRig none(false);
|
||
|
|
Fixture g(none.client);
|
||
|
|
auto res = g.client->post("/agent/optimize/logs", "{\"limit\":5}", json);
|
||
|
|
check(res.status == 503 && contains(res.body, "google_not_configured"),
|
||
|
|
"no credential is a loud 503");
|
||
|
|
check(none.mock->send_count() == 0, "no network without a credential");
|
||
|
|
return finish("agent/optimize/logs");
|
||
|
|
}
|