


















@@ -46,7 +46,8 @@ describe("acp cli option collisions", () => {
46464747function expectCliError(pattern: RegExp) {
4848expect(serveAcpGateway).not.toHaveBeenCalled();
49-expect(defaultRuntime.error).toHaveBeenCalledWith(expect.stringMatching(pattern));
49+const errors = defaultRuntime.error.mock.calls.map(([message]) => String(message));
50+expect(errors.some((message) => pattern.test(message))).toBe(true);
5051expect(defaultRuntime.exit).toHaveBeenCalledWith(1);
5152}
5253@@ -66,11 +67,8 @@ describe("acp cli option collisions", () => {
6667argv: ["acp", "client", "--verbose"],
6768});
686969-expect(runAcpClientInteractive).toHaveBeenCalledWith(
70-expect.objectContaining({
71-verbose: true,
72-}),
73-);
70+expect(runAcpClientInteractive).toHaveBeenCalledTimes(1);
71+expect(runAcpClientInteractive.mock.calls[0]?.[0]?.verbose).toBe(true);
7472});
75737674it("loads gateway token/password from files", async () => {
@@ -88,12 +86,10 @@ describe("acp cli option collisions", () => {
8886},
8987);
908891-expect(serveAcpGateway).toHaveBeenCalledWith(
92-expect.objectContaining({
93-gatewayToken: "tok_file",
94-gatewayPassword: "pw_file", // pragma: allowlist secret
95-}),
96-);
89+expect(serveAcpGateway).toHaveBeenCalledTimes(1);
90+const [gatewayOptions] = serveAcpGateway.mock.calls[0] ?? [];
91+expect(gatewayOptions?.gatewayToken).toBe("tok_file");
92+expect(gatewayOptions?.gatewayPassword).toBe("pw_file"); // pragma: allowlist secret
9793});
98949995it.each([
@@ -125,11 +121,12 @@ describe("acp cli option collisions", () => {
125121it("warns when inline secret flags are used", async () => {
126122await parseAcp(["--token", "tok_inline", "--password", "pw_inline"]);
127123128-expect(defaultRuntime.error).toHaveBeenCalledWith(
129-expect.stringMatching(/--token can be exposed via process listings/),
124+const errors = defaultRuntime.error.mock.calls.map(([message]) => String(message));
125+expect(errors).toContain(
126+"Warning: --token can be exposed via process listings. Prefer --token-file or environment variables.",
130127);
131-expect(defaultRuntime.error).toHaveBeenCalledWith(
132-expect.stringMatching(/--password can be exposed via process listings/),
128+expect(errors).toContain(
129+"Warning: --password can be exposed via process listings. Prefer --password-file or environment variables.",
133130);
134131});
135132@@ -138,11 +135,8 @@ describe("acp cli option collisions", () => {
138135await parseAcp(["--token-file", ` ${files.tokenFile ?? ""} `]);
139136});
140137141-expect(serveAcpGateway).toHaveBeenCalledWith(
142-expect.objectContaining({
143-gatewayToken: "tok_file",
144-}),
145-);
138+expect(serveAcpGateway).toHaveBeenCalledTimes(1);
139+expect(serveAcpGateway.mock.calls[0]?.[0]?.gatewayToken).toBe("tok_file");
146140});
147141148142it("reports missing token-file read errors", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。