Files
OmniRoute/tests/unit/validation-specialty-inline-split.test.ts
Jan Leon 502e614850 fix(vertex): discover and route partner models correctly (#12471)
Merged. Root cause first: `publishers.models.list` was called with `pageSize=1000` against Google's hard maximum of 300, so every publisher answered 400 and discovery silently fell back to the stale static catalog. On top of that the PR separates API-key from Service-Account capabilities correctly (keys cannot list Model Garden — project-scoped curated catalog; SA tokens can — live catalog), stops treating the expected generativelanguage rejection of a Service Account as a discovery failure, replaces the speculative partner IDs with documented MaaS IDs, and rejects OAuth client-config JSON with a clear message instead of a misleading one.

The 5 ESLint errors flagged during the earlier fix sweep were fixed in your own follow-up commits; the branch was reconciled with the release tip and the 42 locale files were checked for lost keys before this merge.

Validated as a combined board first (this PR merged with the 4 siblings of the JxnLexn wave on the release tip): eslint with the frozen suppressions, typecheck:core, check:open-sse-typecheck, complexity, cognitive-complexity, changelog-integrity, docs-sync, migration-numbering, provider-consistency and a duplicate-identifier audit all green, plus 77 passing / 0 failing focused node:test cases across the test files the wave touches. The wave's i18n fill (new keys carried to all 66 locales), free-tier doc counts and file-size rebaseline land in one follow-up PR right after the wave, as with #13904.

Thank you — the credential-capability distinction and the retired/non-chat filtering are what make the Vertex listing trustworthy.
2026-09-16 16:37:41 -03:00

78 lines
3.3 KiB
TypeScript

// Characterization of the validation.ts specialty-inline split (god-file decomposition): the
// inline SPECIALTY_VALIDATORS closures (v0-vercel, auggie, qoder, kiro wrapper, gitlab, vertex,
// vertex-partner, longcat, nvidia, zai, xiaomi-mimo, gitlawb factory) moved into
// validation/specialtyInline.ts as top-level functions taking `isLocal` where the original
// closure captured it. Behavior-preserving move — the locks here are module surface; the runtime
// behavior stays covered by provider-validation-specialty / provider-validation-azure-vertex /
// nvidia-validation-* / zai-validator / xiaomi-mimo-provider suites.
import { test } from "node:test";
import assert from "node:assert/strict";
const M = await import("../../src/lib/providers/validation/specialtyInline.ts");
const HOST = await import("../../src/lib/providers/validation.ts");
test("specialtyInline exposes the extracted leaf validators", () => {
for (const name of [
"validateV0VercelProvider",
"validateAuggieProvider",
"validateQoderProvider",
"validateKiroProvider",
"validateGitlabProvider",
"validateVertexProvider",
"validateVertexPartnerProvider",
"validateLongcatProvider",
"validateNvidiaProvider",
"validateZaiProvider",
"validateXiaomiMimoProvider",
"buildOpengatewayValidator",
"buildGitlawbValidators",
]) {
assert.equal(typeof (M as Record<string, unknown>)[name], "function", `missing ${name}`);
}
});
test("host dispatcher surface stays intact after the move", () => {
assert.equal(typeof (HOST as Record<string, unknown>).validateProviderApiKey, "function");
});
test("buildGitlawbValidators returns one entry per config id", () => {
const map = M.buildGitlawbValidators(
[
["gitlawb", "https://opengateway.gitlawb.com/v1/xiaomi-mimo", "mimo-v2.5-pro"],
["gitlawb-gmi", "https://opengateway.gitlawb.com/v1/gmi-cloud", "XiaomiMiMo/MiMo-V2.5-Pro"],
],
false
);
assert.deepEqual(Object.keys(map).sort(), ["gitlawb", "gitlawb-gmi"]);
assert.equal(typeof map.gitlawb, "function");
assert.equal(typeof map["gitlawb-gmi"], "function");
});
test("validateVertexProvider: Express-mode key is accepted without JWT mint", async () => {
const result = await M.validateVertexProvider({ apiKey: "opaque-express-key" });
assert.equal(result.valid, true);
assert.equal(result.error, null);
});
test("validateVertexPartnerProvider: Express-mode key is accepted without JWT mint", async () => {
const result = await M.validateVertexPartnerProvider({ apiKey: "opaque-express-key" });
assert.equal(result.valid, true);
assert.equal(result.error, null);
});
test("validateVertexProvider: malformed Service Account JSON is rejected", async () => {
const result = await M.validateVertexProvider({
apiKey: '{"type":"service_account","project_id":"p"}',
});
assert.equal(result.valid, false);
assert.match(result.error || "", /Invalid Service Account JSON/i);
});
test("validateVertexProvider: OAuth client JSON explains the required credential type", async () => {
const result = await M.validateVertexProvider({
apiKey: JSON.stringify({ web: { client_id: "example.apps.googleusercontent.com" } }),
});
assert.equal(result.valid, false);
assert.match(result.error || "", /OAuth client JSON is not a Service Account key/i);
});