Files
OmniRoute/tests/unit/issue-9407-gemini-web-validation-false-positive.test.ts
Diego Rodrigues de Sa e Souza ef3f554665 fix(tests): clear the two base-reds on release/v3.8.50 (#9488)
* fix(tests): clear the two base-reds on release/v3.8.50

Both sat on the release itself and turned every open PR red as soon as it
merged the release, independently of the PR's own content.

- tests/snapshots/provider/translate-path.json: #9064 (b0501642dd) added the
  code-execution-2025-08-25 and skills-2025-10-02 beta flags to the Anthropic
  header but did not regenerate the golden. provider-translate-path-golden
  failed on the bare release tip — 2 pass / 1 fail with zero PRs boarded.
  Regenerated; the diff is 24 lines, all the same header in 6 variants.

- tests/unit/v1-models-auth-leak-9320.test.ts:83: shipped a (k: any) in a file
  new enough that eslint-suppressions.json does not cover it. With
  @typescript-eslint/no-explicit-any as error under tests/, that one cast
  failed 'No new ESLint warnings' for every PR. The callback parameter infers
  correctly, so the cast was redundant.

Verified on the fix branch: eslint exit 0, typecheck:core exit 0, and both
test files green (5/5).

* fix(tests): drop a third unsuppressed any (gemini-web validation test)

A full-repo lint on this branch surfaced one more file in the same class:
tests/unit/issue-9407-gemini-web-validation-false-positive.test.ts:50 casts
(executor as any).testConnection. The file entered the release at f1ea77fd04
(23:28), newer than the frozen eslint-suppressions.json, so the cast is not
covered — and it alone kept 'No new ESLint warnings' red on this very PR.

testConnection is a declared public method on GeminiWebExecutor
(open-sse/executors/gemini-web.ts:359), so the cast was redundant rather than
load-bearing; removed outright.

eslint exit 0, typecheck:core exit 0, 15/15 across the three touched tests.
2026-08-05 11:36:19 -03:00

131 lines
4.0 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
/**
* #9407 — gemini-web connection test false-positives
*
* Validates:
* 1. validateGeminiWebProvider detects ServiceLogin redirect (expired session)
* 2. GeminiWebExecutor has testConnection() for cookie format validation
* 3. Queue timeout is reasonable for browser automation lifecycle
*/
describe("validateGeminiWebProvider — ServiceLogin detection (#9407)", () => {
it("source references ServiceLogin and returns valid:false for expired sessions", async () => {
const { validateGeminiWebProvider } = await import(
"@/lib/providers/validation/webProvidersB"
);
const fnStr = validateGeminiWebProvider.toString();
// Regex literal in source: /accounts\.google\.com\/
assert.ok(
fnStr.includes("ServiceLogin"),
"Must detect ServiceLogin specifically"
);
assert.ok(
fnStr.includes('valid:false'),
"ServiceLogin redirect must be classified as invalid"
);
assert.ok(
fnStr.includes('valid:true') && fnStr.includes('warning'),
"Ambiguous redirect must have valid:true with warning"
);
});
it("returns valid:false for missing cookie (early return, no network call)", async () => {
const { validateGeminiWebProvider } = await import(
"@/lib/providers/validation/webProvidersB"
);
const result = await validateGeminiWebProvider({ apiKey: "" });
assert.equal(result.valid, false);
assert.ok(result.error?.includes("Paste your __Secure-1PSID"));
});
});
describe("GeminiWebExecutor — testConnection", () => {
it("has a testConnection method", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
const executor = new GeminiWebExecutor();
assert.equal(typeof executor.testConnection, "function");
});
it("returns false for empty credentials", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(await new GeminiWebExecutor().testConnection({}), false);
});
it("returns false for missing apiKey", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(
await new GeminiWebExecutor().testConnection({ apiKey: "" }),
false
);
});
it("returns false for empty cookie value", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(
await new GeminiWebExecutor().testConnection({
apiKey: "__Secure-1PSID=",
}),
false
);
});
it("returns true for well-formed cookie", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(
await new GeminiWebExecutor().testConnection({
apiKey: "__Secure-1PSID=abc123.def456.ghi789",
}),
true
);
});
it("accepts bare cookie value (without prefix)", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(
await new GeminiWebExecutor().testConnection({
apiKey: "abc123.def456.ghi789",
}),
true
);
});
it("handles providerSpecificData.cookie", async () => {
const { GeminiWebExecutor } = await import(
"@omniroute/open-sse/executors/gemini-web.ts"
);
assert.equal(
await new GeminiWebExecutor().testConnection({
providerSpecificData: { cookie: "__Secure-1PSID=xyz.789" },
}),
true
);
});
});
describe("gemini-web queue timeout", () => {
it("default queueTimeoutMs is at least 30s", async () => {
const { getDefaultComboConfig } = await import(
"@omniroute/open-sse/services/comboConfig.ts"
);
const config = getDefaultComboConfig();
assert.ok(
config.queueTimeoutMs >= 30000,
`queueTimeoutMs should be at least 30s (got ${config.queueTimeoutMs}ms)`
);
});
});