27 lines
1.5 KiB
C++
27 lines
1.5 KiB
C++
// Route: GET /ai/openai/admin, /status, /calls, /audit-events, /webhook-events (no credential needed)
|
|||
|
|
#include "support/Assert.hpp"
|
||
|
|
|
||
|
|
using namespace molo::example::test;
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
unsetenv("OPENAI_ADMIN_KEY");
|
||
|
|
unsetenv("OPENAI_API_KEY");
|
||
|
|
Fixture f;
|
||
|
|
auto page = f.client->get("/ai/openai/admin");
|
||
|
|
check(page.status == 200 && contains(page.body, "OpenAI administration"), "page 200");
|
||
|
|
check(contains(page.body, "/embedded/ai_openai_admin.js"), "page loads its script");
|
||
|
|
auto st = f.client->get("/ai/openai/admin/status");
|
||
|
|
check(st.status == 200 && contains(st.body, "\"configured\":false"), "status without key");
|
||
|
|
check(contains(st.body, "\"calls\":121"), "status counts the table");
|
||
|
|
auto calls = f.client->get("/ai/openai/admin/calls");
|
||
|
|
check(calls.status == 200 && contains(calls.body, "projects.service_accounts.api_keys.create"), "call table listed");
|
||
|
|
check(contains(calls.body, "\"destructive\":true"), "destructive rows flagged");
|
||
|
|
auto audit = f.client->get("/ai/openai/admin/audit-events");
|
||
|
|
check(audit.status == 200 && contains(audit.body, "project.archived"), "audit catalog");
|
||
|
|
auto hooks = f.client->get("/ai/openai/admin/webhook-events");
|
||
|
|
check(hooks.status == 200 && contains(hooks.body, "response.completed"), "webhook catalog");
|
||
|
|
check(f.client->post("/ai/openai/admin/status", "{}", "application/json").status == 405, "post status is 405");
|
||
|
|
check(contains(f.client->get("/").body, "/ai/openai/admin"), "matrix row for the page");
|
||
|
|
return finish("ai/openai/admin/status");
|
||
|
|
}
|