feat(clients): openai admin: organization admin API, usage, costs, audit logs, webhooks
121-call table checked against the OpenAI OpenAPI document, admin-key-only client, destructive guards, WebhookVerifier (Standard Webhooks HMAC-SHA256), demo routes under /ai/openai/admin, local and opt-in live tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Route: POST /ai/openai/admin/read (422 first, then 503 without a credential)
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
unsetenv("OPENAI_ADMIN_KEY");
|
||||
unsetenv("OPENAI_API_KEY");
|
||||
Fixture f;
|
||||
auto post = [&](const std::string& b) {
|
||||
return f.client->post("/ai/openai/admin/read", b, "application/json");
|
||||
};
|
||||
auto ok = post("{\"call\":\"users.list\",\"query\":{\"limit\":5}}");
|
||||
check(ok.status == 503 && contains(ok.body, "not_configured"), "valid read without key is 503");
|
||||
check(post("{\"call\":\"webhook_event_types.list\"}").status == 503, "project-key call without key is 503");
|
||||
check(post("{}").status == 422, "missing call is 422");
|
||||
check(post("{\"call\":\"nope.list\"}").status == 422, "unknown call is 422");
|
||||
check(post("{\"call\":\"users.update\",\"ids\":[\"u\"]}").status == 422, "write via read is 422");
|
||||
check(post("{\"call\":\"users.get\"}").status == 422, "missing id is 422");
|
||||
check(post("{\"call\":\"users.get\",\"ids\":[\"../x\"]}").status == 422, "bad id is 422");
|
||||
check(post("{\"call\":\"users.list\",\"query\":{\"nope\":1}}").status == 422, "foreign query name is 422");
|
||||
check(post("{\"call\":\"users.list\",\"region\":\"zz\"}").status == 422, "bad region is 422");
|
||||
check(post("[1]").status == 422, "non-object body is 422");
|
||||
check(post("{bad").status == 422, "bad json is 422");
|
||||
check(f.client->get("/ai/openai/admin/read").status == 405, "get is 405");
|
||||
return finish("ai/openai/admin/read");
|
||||
}
|
||||
Reference in New Issue
Block a user