The PIN moves from 8.0.42 to 8.0.79 with the upstream archive checksum and the extracted binary checksum. The panel stays 1.26.7. proxy.json keeps the binary path of the PIN it was created under. A path of the form <dataRoot>/opt/cliproxyapi/<version>/cli-proxy-api now validates and reads as the current pinned path, so an instance created on 8.0.42 needs no edit. The runner still runs only the verified pinned install. 8.0.79 applies a key-list PUT by an async reload a few milliseconds after it answers, so a just-issued key answers 401 at first. Preflight now probes again on 401 only, for at most ISSUE_PROBE_TIMEOUT_MS (2 s). Any other non-2xx still refuses on the first answer.
26 lines
2.0 KiB
JavaScript
26 lines
2.0 KiB
JavaScript
// P2 named settings refuse independently; legacy sidecars retain their shape.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { validateProxy, installPaths } from '../src/settings.mjs';
|
|
const dataRoot = '/fixture-data';
|
|
const base = { port: 18432, binary: installPaths(dataRoot).binary };
|
|
test('proxy settings without optional timing fields remain valid', () => assert.deepEqual(validateProxy(base, dataRoot), base));
|
|
test('proxy settings accept each positive upper bound', () => {
|
|
assert.deepEqual(validateProxy({ ...base, rotateGraceMinutes: 1440, firstOutputSeconds: 3600 }, dataRoot), { ...base, rotateGraceMinutes: 1440, firstOutputSeconds: 3600 });
|
|
});
|
|
for (const [field, maximum, code] of [['rotateGraceMinutes', 1440, 'proxy-rotate-grace-invalid'], ['firstOutputSeconds', 3600, 'proxy-first-output-invalid']]) {
|
|
for (const value of [0, -1, maximum + 1, 1.5, '120', null]) test(`${code}: ${JSON.stringify(value)}`, () => {
|
|
assert.throws(() => validateProxy({ ...base, [field]: value }, dataRoot), e => e.code === code);
|
|
});
|
|
}
|
|
// #1873 PIN bump: a sidecar written under an earlier PIN keeps the instance config valid.
|
|
test('a proxy.json written under an earlier PIN reads as the current pinned path', () => {
|
|
const old = { ...base, binary: '/fixture-data/opt/cliproxyapi/8.0.42/cli-proxy-api' };
|
|
assert.deepEqual(validateProxy(old, dataRoot), base);
|
|
assert.deepEqual(validateProxy({ ...old, rotateGraceMinutes: 60 }, dataRoot), { ...base, rotateGraceMinutes: 60 });
|
|
});
|
|
for (const binary of ['/bad', '/fixture-data/opt/cliproxyapi/8.0.42/other', '/fixture-data/opt/cliproxyapi/latest/cli-proxy-api',
|
|
'/fixture-data/opt/cliproxyapi/8.0.42/x/cli-proxy-api', '/fixture-data/opt/cliproxyapi/../cliproxyapi/8.0.42/cli-proxy-api',
|
|
'/other-data/opt/cliproxyapi/8.0.42/cli-proxy-api', '/fixture-data/opt/cliproxyapi/8.0/cli-proxy-api', 7])
|
|
test(`proxy-config-invalid: binary ${JSON.stringify(binary)}`, () => assert.throws(() => validateProxy({ ...base, binary }, dataRoot), e => e.code === 'proxy-config-invalid'));
|