mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:50:43 +00:00
test: share config audit record setup
This commit is contained in:
@@ -10,32 +10,36 @@ import {
|
||||
resolveConfigAuditLogPath,
|
||||
} from "./io.audit.js";
|
||||
|
||||
function createAuditRecordBase(configPath: string) {
|
||||
return createConfigWriteAuditRecordBase({
|
||||
configPath,
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
existsBefore: true,
|
||||
previousHash: "prev-hash",
|
||||
nextHash: "next-hash",
|
||||
previousBytes: 12,
|
||||
nextBytes: 24,
|
||||
previousMetadata: {
|
||||
dev: "10",
|
||||
ino: "11",
|
||||
mode: 0o600,
|
||||
nlink: 1,
|
||||
uid: 501,
|
||||
gid: 20,
|
||||
},
|
||||
changedPathCount: 1,
|
||||
hasMetaBefore: true,
|
||||
hasMetaAfter: true,
|
||||
gatewayModeBefore: "local",
|
||||
gatewayModeAfter: "local",
|
||||
suspicious: [],
|
||||
now: "2026-04-07T08:00:00.000Z",
|
||||
});
|
||||
}
|
||||
|
||||
function createRenameAuditRecord(home: string) {
|
||||
return finalizeConfigWriteAuditRecord({
|
||||
base: createConfigWriteAuditRecordBase({
|
||||
configPath: path.join(home, ".openclaw", "openclaw.json"),
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
existsBefore: true,
|
||||
previousHash: "prev-hash",
|
||||
nextHash: "next-hash",
|
||||
previousBytes: 12,
|
||||
nextBytes: 24,
|
||||
previousMetadata: {
|
||||
dev: "10",
|
||||
ino: "11",
|
||||
mode: 0o600,
|
||||
nlink: 1,
|
||||
uid: 501,
|
||||
gid: 20,
|
||||
},
|
||||
changedPathCount: 1,
|
||||
hasMetaBefore: true,
|
||||
hasMetaAfter: true,
|
||||
gatewayModeBefore: "local",
|
||||
gatewayModeAfter: "local",
|
||||
suspicious: [],
|
||||
now: "2026-04-07T08:00:00.000Z",
|
||||
}),
|
||||
base: createAuditRecordBase(path.join(home, ".openclaw", "openclaw.json")),
|
||||
result: "rename",
|
||||
nextMetadata: {
|
||||
dev: "12",
|
||||
@@ -155,30 +159,7 @@ describe("config io audit helpers", () => {
|
||||
});
|
||||
|
||||
it("drops next-file metadata and preserves error details for failed writes", () => {
|
||||
const base = createConfigWriteAuditRecordBase({
|
||||
configPath: "/tmp/openclaw.json",
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
existsBefore: true,
|
||||
previousHash: "prev-hash",
|
||||
nextHash: "next-hash",
|
||||
previousBytes: 12,
|
||||
nextBytes: 24,
|
||||
previousMetadata: {
|
||||
dev: "10",
|
||||
ino: "11",
|
||||
mode: 0o600,
|
||||
nlink: 1,
|
||||
uid: 501,
|
||||
gid: 20,
|
||||
},
|
||||
changedPathCount: 1,
|
||||
hasMetaBefore: true,
|
||||
hasMetaAfter: true,
|
||||
gatewayModeBefore: "local",
|
||||
gatewayModeAfter: "local",
|
||||
suspicious: [],
|
||||
now: "2026-04-07T08:00:00.000Z",
|
||||
});
|
||||
const base = createAuditRecordBase("/tmp/openclaw.json");
|
||||
const err = Object.assign(new Error("disk full"), { code: "ENOSPC" });
|
||||
const record = finalizeConfigWriteAuditRecord({
|
||||
base,
|
||||
|
||||
Reference in New Issue
Block a user