mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
fix(qa): reject loose Parallels host ports
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
makeTempDir,
|
||||
parseBoolEnv,
|
||||
parseMode,
|
||||
parsePositiveInt,
|
||||
parseProvider,
|
||||
readPositiveIntEnv,
|
||||
modelProviderConfigBatchJson,
|
||||
@@ -201,7 +202,7 @@ export function parseArgs(argv: string[]): LinuxOptions {
|
||||
i++;
|
||||
break;
|
||||
case "--host-port":
|
||||
options.hostPort = Number(ensureValue(args, i, arg));
|
||||
options.hostPort = parsePositiveInt(ensureValue(args, i, arg), arg);
|
||||
options.hostPortExplicit = true;
|
||||
i++;
|
||||
break;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
currentRunningSnapshotInfo,
|
||||
makeTempDir,
|
||||
parseMode,
|
||||
parsePositiveInt,
|
||||
parseProvider,
|
||||
readPositiveIntEnv,
|
||||
resolveLatestVersion,
|
||||
@@ -156,7 +157,7 @@ export function parseArgs(argv: string[]): WindowsOptions {
|
||||
options.hostIp = value;
|
||||
},
|
||||
"--host-port": (value) => {
|
||||
options.hostPort = Number(value);
|
||||
options.hostPort = parsePositiveInt(value, "--host-port");
|
||||
options.hostPortExplicit = true;
|
||||
},
|
||||
"--install-url": (value) => {
|
||||
|
||||
@@ -164,6 +164,8 @@ describe("Parallels smoke model selection", () => {
|
||||
let missingProviderKeyResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidModelTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidHostPortResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidLinuxHostPortResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidWindowsHostPortResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidLinuxAgentTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidWindowsAgentTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
let invalidWindowsUpdateTimeoutResult: ReturnType<typeof spawnNodeEvalSync>;
|
||||
@@ -202,6 +204,14 @@ describe("Parallels smoke model selection", () => {
|
||||
`process.argv = ["node", "${TS_PATHS.macos}", "--host-port", "18425x"]; await import("./${TS_PATHS.macos}");`,
|
||||
{ env: process.env, imports: ["tsx"] },
|
||||
);
|
||||
invalidLinuxHostPortResult = spawnNodeEvalSync(
|
||||
`process.argv = ["node", "${TS_PATHS.linux}", "--host-port", "1e4"]; await import("./${TS_PATHS.linux}");`,
|
||||
{ env: process.env, imports: ["tsx"] },
|
||||
);
|
||||
invalidWindowsHostPortResult = spawnNodeEvalSync(
|
||||
`process.argv = ["node", "${TS_PATHS.windows}", "--host-port", "0x4800"]; await import("./${TS_PATHS.windows}");`,
|
||||
{ env: process.env, imports: ["tsx"] },
|
||||
);
|
||||
invalidLinuxAgentTimeoutResult = spawnNodeEvalSync(
|
||||
`process.env.OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S = "1e3"; process.argv = ["node", "${TS_PATHS.linux}"]; await import("./${TS_PATHS.linux}");`,
|
||||
{ env: process.env, imports: ["tsx"] },
|
||||
@@ -1401,6 +1411,12 @@ setInterval(() => {}, 1000);
|
||||
expect(invalidHostPortResult.status).toBe(1);
|
||||
expect(invalidHostPortResult.stderr).toContain("invalid --host-port: 18425x");
|
||||
|
||||
expect(invalidLinuxHostPortResult.status).toBe(1);
|
||||
expect(invalidLinuxHostPortResult.stderr).toContain("invalid --host-port: 1e4");
|
||||
|
||||
expect(invalidWindowsHostPortResult.status).toBe(1);
|
||||
expect(invalidWindowsHostPortResult.stderr).toContain("invalid --host-port: 0x4800");
|
||||
|
||||
expect(invalidLinuxAgentTimeoutResult.status).toBe(1);
|
||||
expect(invalidLinuxAgentTimeoutResult.stderr).toContain(
|
||||
"invalid OPENCLAW_PARALLELS_LINUX_AGENT_TIMEOUT_S: 1e3",
|
||||
|
||||
Reference in New Issue
Block a user