43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
// Route: GET /agent/live/status (credential form and static caps)
|
|
#include <cstdlib>
|
|
|
|
#include "support/GoogleRig.hpp"
|
|
|
|
using namespace molo::example::test;
|
|
|
|
int main() {
|
|
unsetenv("GOOGLE_ACCESS_TOKEN");
|
|
setenv("GOOGLE_API_KEY", "AIzaTEST-LIVE-KEY", 1);
|
|
unsetenv("GOOGLE_LIVE_URL");
|
|
{
|
|
GoogleRig rig;
|
|
Fixture f(rig.client);
|
|
auto res = f.client->get("/agent/live/status");
|
|
check(res.status == 200, "status 200");
|
|
check(contains(res.headers.get("Content-Type"), "application/json"), "json");
|
|
check(contains(res.body, "\"configured\":true"), "configured with a key");
|
|
check(contains(res.body, "\"auth_mode\":\"gemini_api_key\""), "plain key selects the Gemini API form");
|
|
check(contains(res.body, "\"max_sessions\":8"), "caps shown");
|
|
check(!contains(res.body, "AIzaTEST-LIVE-KEY"), "credential never shown");
|
|
check(rig.mock->send_count() == 0, "side effect: no upstream traffic");
|
|
}
|
|
setenv("GOOGLE_API_KEY", "AQ.test-express", 1);
|
|
setenv("GOOGLE_CLOUD_PROJECT", "test-project", 1);
|
|
{
|
|
GoogleRig rig;
|
|
Fixture f(rig.client);
|
|
check(contains(f.client->get("/agent/live/status").body, "\"auth_mode\":\"vertex_express\""),
|
|
"AQ. key with a project selects Vertex express");
|
|
}
|
|
unsetenv("GOOGLE_API_KEY");
|
|
{
|
|
GoogleRig rig(false);
|
|
Fixture f(rig.client);
|
|
check(contains(f.client->get("/agent/live/status").body, "\"configured\":false"),
|
|
"not configured without a credential");
|
|
}
|
|
Fixture f;
|
|
check(f.client->post("/agent/live/status").status == 405, "post is 405");
|
|
return finish("agent/live/status");
|
|
}
|