Adds molo::google::apis (api_catalog) as the code source of truth, src/google/APIS.md, a Required APIs section per module SPEC, and the vendor key consoles in src/llm/SPEC.md. Placeholder project example-214512124. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
48 lines
2.0 KiB
C++
48 lines
2.0 KiB
C++
// The API catalog: every service has a well-formed activation URL.
|
|
#include <set>
|
|
|
|
#include "framework.h"
|
|
#include "google/api_catalog.h"
|
|
#include "google/errors.h"
|
|
|
|
using namespace molo::google;
|
|
|
|
TEST(api_catalog, services_unique_and_well_formed) {
|
|
std::set<std::string> seen;
|
|
const std::string suffix = ".googleapis.com";
|
|
for (const auto& api : apis::all()) {
|
|
ASSERT_TRUE(seen.insert(api.service).second);
|
|
ASSERT_TRUE(api.service.size() > suffix.size());
|
|
ASSERT_EQ(api.service.substr(api.service.size() - suffix.size()), suffix);
|
|
ASSERT_FALSE(api.title.empty());
|
|
ASSERT_FALSE(api.used_by.empty());
|
|
}
|
|
ASSERT_TRUE(apis::all().size() >= 12u);
|
|
}
|
|
|
|
TEST(api_catalog, enable_url_matches_google_activation_page) {
|
|
ASSERT_EQ(apis::enable_url("agentregistry.googleapis.com", apis::kExampleProject),
|
|
"https://console.developers.google.com/apis/api/agentregistry.googleapis.com/"
|
|
"overview?project=example-214512124");
|
|
ASSERT_EQ(apis::enable_command("iamcredentials.googleapis.com", apis::kExampleProject),
|
|
"gcloud services enable iamcredentials.googleapis.com --project=example-214512124");
|
|
}
|
|
|
|
TEST(api_catalog, example_project_valid_and_bad_ids_rejected) {
|
|
ASSERT_TRUE(apis::valid_project(apis::kExampleProject));
|
|
ASSERT_FALSE(apis::valid_project("Short"));
|
|
ASSERT_FALSE(apis::valid_project("1starts-with-digit"));
|
|
ASSERT_FALSE(apis::valid_project("ends-with-hyphen-"));
|
|
ASSERT_FALSE(apis::valid_project("has_underscore"));
|
|
ASSERT_FALSE(apis::valid_project(std::string(31, 'a')));
|
|
ASSERT_THROW(apis::enable_url("agentregistry.googleapis.com", "bad id"), GoogleError);
|
|
ASSERT_THROW(apis::enable_url("nope.googleapis.com", apis::kExampleProject), GoogleError);
|
|
}
|
|
|
|
TEST(api_catalog, credential_pages) {
|
|
ASSERT_EQ(apis::api_keys_url(apis::kExampleProject),
|
|
"https://console.cloud.google.com/apis/credentials?project=example-214512124");
|
|
ASSERT_EQ(apis::service_accounts_url(apis::kExampleProject),
|
|
"https://console.cloud.google.com/iam-admin/serviceaccounts?project=example-214512124");
|
|
}
|