test(auth): isolated import fixtures from broker env

Saved and cleared ambient auth-broker settings around local-store import tests, then restored them after each case.

Fixes #5782
This commit is contained in:
roboomp
2026-07-17 02:55:39 +00:00
parent b0d04e5173
commit 7e47a1d36b
2 changed files with 13 additions and 0 deletions
+4
View File
@@ -6,6 +6,10 @@
- `retry.fallbackChains` wildcards now support id-prefixed targets and keys: a chain entry like `"openrouter/google/*"` re-prefixes the failing model's bare id (`google-antigravity/gemini-x` → `openrouter/google/gemini-x`), a plain `"provider/*"` entry falling back *from* an aggregator strips the vendor prefix when the target provider only knows the bare id (`openrouter/google/x` → `google-vertex/x`), and an id-prefixed key (`"openrouter/google/*"`) scopes a chain to that provider's ids under the prefix.
### Fixed
- Isolated the CLIProxyAPI auth-broker import tests from ambient broker configuration so fixture credentials cannot be uploaded to a live broker ([#5782](https://github.com/can1357/oh-my-pi/issues/5782)).
## [17.0.1] - 2026-07-16
### Changed
@@ -22,9 +22,14 @@ describe("auth-broker import (CLIProxyAPI)", () => {
let agentDir = "";
let cliproxyDir = "";
let originalAgentDir: string | undefined;
const savedEnv: Record<string, string | undefined> = {};
beforeEach(async () => {
originalAgentDir = process.env.OMP_AGENT_DIR;
savedEnv.OMP_AUTH_BROKER_URL = process.env.OMP_AUTH_BROKER_URL;
savedEnv.OMP_AUTH_BROKER_TOKEN = process.env.OMP_AUTH_BROKER_TOKEN;
delete process.env.OMP_AUTH_BROKER_URL;
delete process.env.OMP_AUTH_BROKER_TOKEN;
agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "omp-import-agent-"));
cliproxyDir = await fs.mkdtemp(path.join(os.tmpdir(), "omp-import-cliproxy-"));
setAgentDir(agentDir);
@@ -36,6 +41,10 @@ describe("auth-broker import (CLIProxyAPI)", () => {
else process.env.OMP_AGENT_DIR = originalAgentDir;
await removeWithRetries(agentDir);
await removeWithRetries(cliproxyDir);
for (const key of ["OMP_AUTH_BROKER_URL", "OMP_AUTH_BROKER_TOKEN"] as const) {
if (savedEnv[key] === undefined) delete process.env[key];
else process.env[key] = savedEnv[key];
}
});
async function writeCliProxyJson(name: string, body: Record<string, unknown>): Promise<string> {