mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(qa): reject short flag gateway smoke values
This commit is contained in:
@@ -56,7 +56,7 @@ function validateArgs(argv: readonly string[]): void {
|
||||
}
|
||||
if (VALUE_FLAGS.has(arg)) {
|
||||
const value = argv[index + 1];
|
||||
if (!value || value.startsWith("--")) {
|
||||
if (!value || value.startsWith("-")) {
|
||||
throw new GatewaySmokeArgError(`${arg} requires a value`);
|
||||
}
|
||||
index += 1;
|
||||
|
||||
@@ -203,6 +203,26 @@ describe("gateway-smoke", () => {
|
||||
expect(result.stderr.trim()).toBe("Unknown argument: --wat");
|
||||
});
|
||||
|
||||
it("rejects option-looking CLI values before connecting", () => {
|
||||
for (const [flag, args] of [
|
||||
["--url", ["--url", "-h", "--token", "token"]],
|
||||
["--token", ["--url", "ws://127.0.0.1:9", "--token", "-h"]],
|
||||
] as const) {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
["--import", "tsx", "scripts/dev/gateway-smoke.ts", ...args],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr.trim()).toBe(`${flag} requires a value`);
|
||||
}
|
||||
});
|
||||
|
||||
it("passes against a loopback gateway websocket using the real client", async () => {
|
||||
const stdout: string[] = [];
|
||||
const stderr: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user