Files
OmniRoute/tests/unit/proxy-noauth-provider-6272.test.ts
Tushar Agarwal 1089c24bc8 Remove/mimocode sunset provider (#10186)
* remove: drop sunset MiMoCode provider from model catalog

* remove: drop sunset MiMoCode provider from model catalog (shared.ts)

Remove unused imports, types, and comments from shared.ts.

* remove: MiMoCode provider (Xiaomi sunset) — executor, registry, no-auth config, icon, tests

* refactor(providers): finish MiMoCode removal — sweep remaining no-auth references

Drop the leftover mimocode entries from the no-auth provider controls, the
translate-path snapshot, the eslint suppressions, and the #3061 auth-loop
test. Re-point the fingerprint-pin (#6696) and proxy-noauth (#6272) tests at
opencode, which exercises the same fingerprint path, so the removal does not
break runtime behavior.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* docs(providers): reconcile provider/executor counts after MiMoCode sunset

The base's parallel doc-count sync (#10433) pinned 340 providers / 101
executors. With mimocode removed, live code has 339 providers and 100
executors; refresh the user-facing counts (package.json description,
llm.txt, README/AGENTS, i18n llm.txt, provider reference, diagrams) so the
check-docs-counts STRICT gate stays green.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

* test(providers): fix orphaned mimocode references after MiMoCode sunset

The sunset removed mimocode/mcode from the free-onboarding candidates and
from FINGERPRINT_PROVIDERS, but two tests still referenced them:

- free-provider-onboarding-setup: the mimocode->theoldllm substitution
  introduced duplicate 'opencode' rows (impossible given the request-set
  dedupe) and the wrong display name; align expectations with the actual
  {opencode, theoldllm} dedupe behavior and 'The Old LLM (Free)' name.
- combo-system-prompt-templates-5501: resolveTargetFingerprint tested with
  provider 'mcode', which is no longer a fingerprint provider; point it at
  the remaining fingerprint provider 'opencode'.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Tushar49 <Tushar49@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: adevwithpurpose <adevwithpurpose@users.noreply.github.com>
Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
2026-08-18 10:49:24 -03:00

94 lines
3.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-6272-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const ORIGINAL_INITIAL_PASSWORD = process.env.INITIAL_PASSWORD;
delete process.env.INITIAL_PASSWORD;
const core = await import("../../src/lib/db/core.ts");
const settingsDb = await import("../../src/lib/db/settings.ts");
const { safeResolveProxy } = await import("../../src/sse/handlers/chatHelpers.ts");
test.after(async () => {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
if (ORIGINAL_INITIAL_PASSWORD === undefined) delete process.env.INITIAL_PASSWORD;
else process.env.INITIAL_PASSWORD = ORIGINAL_INITIAL_PASSWORD;
});
test("#6272: resolveProxyForConnection('noauth', ...) honors a provider-level proxy assigned to 'opencode'", async () => {
core.getDbInstance();
const proxy = { type: "http", host: "127.0.0.1", port: 8888 };
// Reporter's second symptom: "same thing happen when i set the proxy directly
// in the provider menu" -> assign a provider-scoped proxy to the opencode
// provider id, the way Settings -> Providers -> opencode would persist it.
await settingsDb.setProxyForLevel("provider", "opencode", proxy);
const resolved = await settingsDb.resolveProxyForConnection("noauth", undefined);
assert.equal(
resolved?.proxy?.host,
"127.0.0.1",
`expected the opencode provider-level proxy to be honored, got level=${resolved?.level} proxy=${JSON.stringify(resolved?.proxy)}`
);
assert.equal(resolved?.level, "provider");
assert.equal(resolved?.levelId, "opencode");
});
test("control: resolveProxyForConnection('noauth', ...) still honors the GLOBAL proxy when no no-auth provider proxy is set", async () => {
core.getDbInstance();
await settingsDb.deleteProxyForLevel("provider", "opencode");
const proxy = { type: "http", host: "10.0.0.1", port: 9999 };
await settingsDb.setProxyForLevel("global", null, proxy);
const resolved = await settingsDb.resolveProxyForConnection("noauth", undefined);
assert.equal(resolved?.proxy?.host, "10.0.0.1");
assert.equal(resolved?.level, "global");
});
test("resolveProxyForConnection keeps provider-level no-auth proxies isolated", async () => {
core.getDbInstance();
await settingsDb.deleteProxyForLevel("global", null);
await settingsDb.setProxyForLevel("provider", "opencode", {
type: "http",
host: "127.0.0.2",
port: 8889,
});
await settingsDb.setProxyForLevel("provider", "theoldllm", {
type: "http",
host: "127.0.0.3",
port: 8890,
});
const opencode = await settingsDb.resolveProxyForConnection("noauth", undefined, "opencode");
const theOldLlm = await settingsDb.resolveProxyForConnection("noauth", undefined, "theoldllm");
assert.equal(opencode?.proxy?.host, "127.0.0.2");
assert.equal(theOldLlm?.proxy?.host, "127.0.0.3");
});
test("safeResolveProxy keeps the synthetic no-auth connection provider-specific", async () => {
core.getDbInstance();
await settingsDb.setProxyForLevel("provider", "opencode", {
type: "http",
host: "127.0.0.4",
port: 8891,
});
await settingsDb.setProxyForLevel("provider", "theoldllm", {
type: "http",
host: "127.0.0.5",
port: 8892,
});
const opencode = await safeResolveProxy("noauth", undefined, "opencode");
const theOldLlm = await safeResolveProxy("noauth", undefined, "theoldllm");
assert.equal(opencode?.proxy?.host, "127.0.0.4");
assert.equal(theOldLlm?.proxy?.host, "127.0.0.5");
});