Skip to content

Commit 52b07b4

Browse files
committed
test(ci): stabilize ARM changed-test guards
1 parent fa3901e commit 52b07b4

2 files changed

Lines changed: 12 additions & 38 deletions

File tree

src/gateway/server-restart-sentinel.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ describe("scheduleRestartSentinelWake", () => {
11731173
} as Awaited<ReturnType<typeof mocks.readRestartSentinel>>);
11741174
mocks.recordInboundSessionAndDispatchReply.mockImplementation(async (params) => {
11751175
attempt += 1;
1176-
if (attempt <= 6) {
1176+
if (attempt <= 2) {
11771177
await params.deliver({ text: busyReply });
11781178
return;
11791179
}
@@ -1185,16 +1185,19 @@ describe("scheduleRestartSentinelWake", () => {
11851185

11861186
await scheduleRestartSentinelWake({ deps: {} as never });
11871187

1188-
expect(mocks.recordInboundSessionAndDispatchReply).toHaveBeenCalledTimes(7);
1188+
expectMockCallFields(mocks.enqueueSessionDelivery, {
1189+
maxRetries: 20,
1190+
});
1191+
expect(mocks.recordInboundSessionAndDispatchReply).toHaveBeenCalledTimes(3);
11891192
expectContinuationDispatchFields(
11901193
{},
11911194
{ MessageSid: "restart-sentinel:agent:main:main:agentTurn:123" },
11921195
0,
11931196
);
11941197
expectContinuationDispatchFields(
11951198
{},
1196-
{ MessageSid: "restart-sentinel:agent:main:main:agentTurn:123:retry:6" },
1197-
6,
1199+
{ MessageSid: "restart-sentinel:agent:main:main:agentTurn:123:retry:2" },
1200+
2,
11981201
);
11991202
const deliveredBusyReply = (
12001203
mocks.deliverOutboundPayloads.mock.calls as unknown as Array<
@@ -1212,7 +1215,7 @@ describe("scheduleRestartSentinelWake", () => {
12121215
payloads: [{ text: "restart message" }],
12131216
});
12141217
expect(mocks.logWarn.mock.calls).toEqual(
1215-
Array.from({ length: 6 }, () => [
1218+
Array.from({ length: 2 }, () => [
12161219
"restart continuation: retry failed for entry session-delivery-1: Error: restart continuation deferred because previous run is still shutting down",
12171220
]),
12181221
);

src/security/audit-config-include-perms.test.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,19 @@
22
import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
5-
import { beforeEach, describe, expect, it, vi } from "vitest";
5+
import { describe, expect, it } from "vitest";
66
import type { ConfigFileSnapshot } from "../config/types.openclaw.js";
7-
8-
const inspectPathPermissionsMock = vi.hoisted(() => vi.fn());
9-
10-
vi.mock("./audit-fs.js", () => ({
11-
inspectPathPermissions: inspectPathPermissionsMock,
12-
formatPermissionDetail: (targetPath: string) => `${targetPath} mocked-perms`,
13-
formatPermissionRemediation: ({ targetPath }: { targetPath: string }) =>
14-
`chmod 600 ${targetPath}`,
15-
}));
7+
import { collectIncludeFilePermFindings } from "./audit-extra.async.js";
168

179
describe("security audit config include permissions", () => {
18-
beforeEach(() => {
19-
vi.resetModules();
20-
inspectPathPermissionsMock.mockReset();
21-
});
22-
2310
it("flags group/world-readable config include files", async () => {
24-
const { collectIncludeFilePermFindings } = await import("./audit-extra.async.js");
2511
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-include-perms-"));
2612
const stateDir = path.join(tmp, "state");
2713
fs.mkdirSync(stateDir, { recursive: true, mode: 0o700 });
2814

2915
const includePath = path.join(stateDir, "extra.json5");
3016
fs.writeFileSync(includePath, "{ logging: { redactSensitive: 'off' } }\n", "utf-8");
31-
inspectPathPermissionsMock.mockResolvedValue({
32-
ok: true,
33-
isSymlink: false,
34-
isDir: false,
35-
mode: 0o644,
36-
bits: 0o644,
37-
source: "posix",
38-
worldWritable: false,
39-
groupWritable: false,
40-
worldReadable: true,
41-
groupReadable: true,
42-
});
17+
fs.chmodSync(includePath, 0o644);
4318

4419
const configSnapshot: ConfigFileSnapshot = {
4520
path: path.join(stateDir, "openclaw.json"),
@@ -58,13 +33,9 @@ describe("security audit config include permissions", () => {
5833

5934
const findings = await collectIncludeFilePermFindings({
6035
configSnapshot,
36+
platform: "linux",
6137
});
6238

63-
expect(inspectPathPermissionsMock).toHaveBeenCalledWith(includePath, {
64-
env: undefined,
65-
exec: undefined,
66-
platform: undefined,
67-
});
6839
const finding = findings.find(
6940
(entry) => entry.checkId === "fs.config_include.perms_world_readable",
7041
);

0 commit comments

Comments
 (0)