fix(clients): express endpoints are key-only; has_oauth covers service accounts; make google-live
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,7 +75,9 @@ bool invalid_without_traffic(Rig& rig, const std::function<void()>& fn) {
|
||||
class EnvGuard {
|
||||
public:
|
||||
EnvGuard() {
|
||||
for (const char* k : {"GOOGLE_ACCESS_TOKEN", "GOOGLE_CLOUD_PROJECT"}) {
|
||||
for (const char* k : {"GOOGLE_ACCESS_TOKEN", "GOOGLE_ACCESS_TOKEN_FILE",
|
||||
"GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CLOUD_PROJECT",
|
||||
"MOLO_ENV_FILES", "MOLO_LIVE_NET"}) {
|
||||
const char* v = std::getenv(k);
|
||||
saved_.push_back({k, v != nullptr, v ? v : ""});
|
||||
}
|
||||
@@ -126,6 +128,10 @@ TEST(optimize_model, oauth_with_a_project_uses_the_global_project_path) {
|
||||
TEST(optimize_model, without_a_token_it_is_vertex_express) {
|
||||
EnvGuard guard;
|
||||
unsetenv("GOOGLE_ACCESS_TOKEN");
|
||||
unsetenv("GOOGLE_ACCESS_TOKEN_FILE");
|
||||
unsetenv("GOOGLE_APPLICATION_CREDENTIALS");
|
||||
unsetenv("MOLO_LIVE_NET");
|
||||
setenv("MOLO_ENV_FILES", "off", 1); // no .env.json.local service account
|
||||
setenv("GOOGLE_CLOUD_PROJECT", "p1", 1);
|
||||
Rig rig;
|
||||
auto model = make_gemini_model(rig.client, "m1");
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST(optimize_live, evaluate_instances_computation_metrics) {
|
||||
TEST(optimize_live, resource_lists_need_oauth) {
|
||||
if (!live("optimize_live.resource_lists_need_oauth", true)) return;
|
||||
EvaluationResources res(GoogleClient::from_env(), CloudContext::from_env());
|
||||
if (Credentials::env("GOOGLE_ACCESS_TOKEN").empty()) {
|
||||
if (!Credentials::has_oauth()) {
|
||||
// Verified 2026-10-24: API keys are refused with 401 UNAUTHENTICATED.
|
||||
try {
|
||||
res.list(Collection::kEvaluationRuns, ListOptions{1, "", "", 1});
|
||||
@@ -68,7 +68,7 @@ TEST(optimize_live, resource_lists_need_oauth) {
|
||||
|
||||
TEST(optimize_live, observability_reads_with_oauth) {
|
||||
if (!live("optimize_live.observability_reads_with_oauth", true)) return;
|
||||
if (Credentials::env("GOOGLE_ACCESS_TOKEN").empty()) {
|
||||
if (!Credentials::has_oauth()) {
|
||||
std::cout << "SKIP optimize_live.observability_reads_with_oauth (needs GOOGLE_ACCESS_TOKEN)\n";
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user