mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 02:42:24 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
deriveLegacyCliToken,
|
|
deriveMachineToken,
|
|
getMachineTokenSync,
|
|
} from "../../../src/lib/machineToken.ts";
|
|
|
|
test("machine-token derivation fails closed for a missing machine ID", () => {
|
|
assert.equal(deriveMachineToken("", "omniroute-cli-auth-v1"), "");
|
|
assert.equal(deriveLegacyCliToken("", "omniroute-cli-auth-v1"), "");
|
|
});
|
|
|
|
test("getMachineTokenSync returns a 64-character hex string (full SHA-256)", () => {
|
|
const token = getMachineTokenSync();
|
|
assert.match(token, /^[0-9a-f]{64}$/, "token must be 64 lowercase hex chars (HMAC-SHA256)");
|
|
});
|
|
|
|
test("getMachineTokenSync is deterministic", () => {
|
|
assert.equal(getMachineTokenSync(), getMachineTokenSync());
|
|
});
|
|
|
|
test("getMachineTokenSync produces different values for different salts", () => {
|
|
const t1 = getMachineTokenSync("salt-a");
|
|
const t2 = getMachineTokenSync("salt-b");
|
|
assert.notEqual(t1, t2);
|
|
});
|
|
|
|
test("getMachineTokenSync with empty string salt does not throw", () => {
|
|
assert.doesNotThrow(() => getMachineTokenSync(""));
|
|
});
|
|
|
|
test("getMachineTokenSync respects OMNIROUTE_CLI_SALT env var", () => {
|
|
const previous = process.env.OMNIROUTE_CLI_SALT;
|
|
try {
|
|
const before = getMachineTokenSync();
|
|
process.env.OMNIROUTE_CLI_SALT = "__test_salt__";
|
|
const withEnv = getMachineTokenSync();
|
|
assert.notEqual(before, withEnv, "env salt must produce a different token");
|
|
assert.match(withEnv, /^[0-9a-f]{64}$/, "env-derived token must still be 64-char hex");
|
|
} finally {
|
|
if (previous === undefined) delete process.env.OMNIROUTE_CLI_SALT;
|
|
else process.env.OMNIROUTE_CLI_SALT = previous;
|
|
}
|
|
});
|