mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
test(release): redact shared failure diagnostics (#125697)
* test(release): use shared channel diagnostics * fix(release): redact shared E2E failure logs * test(release): configure redaction timeout fixture
This commit is contained in:
@@ -118,9 +118,15 @@ function createPackageInstallFixture(tempDir: string) {
|
||||
npmArgsPath: path.join(tempDir, "npm-args.txt"),
|
||||
packagePath: path.join(tempDir, "openclaw.tgz"),
|
||||
prefixPath: path.join(tempDir, "prefix"),
|
||||
redactorPath: path.join(tempDir, "redactor.mjs"),
|
||||
timeoutArgsPath: path.join(tempDir, "timeout-args.txt"),
|
||||
};
|
||||
writePackageFixture(fixture.packagePath);
|
||||
fs.writeFileSync(
|
||||
fixture.redactorPath,
|
||||
"export const redactSensitiveText = (value) => value;\n",
|
||||
"utf8",
|
||||
);
|
||||
return fixture;
|
||||
}
|
||||
|
||||
@@ -132,7 +138,7 @@ function runPackageInstall(
|
||||
[
|
||||
`openclaw_e2e_install_package ${shellQuote(fixture.logPath)} ${shellQuote("fixture package")} ${shellQuote(fixture.prefixPath)}`,
|
||||
],
|
||||
env,
|
||||
{ ...env, OPENCLAW_E2E_REDACTOR_MODULE: fixture.redactorPath },
|
||||
undefined,
|
||||
"; ",
|
||||
);
|
||||
@@ -878,6 +884,12 @@ exit 1
|
||||
const logLabel = path.basename(tempDir);
|
||||
const logDir = path.join(tempDir, "logs");
|
||||
const timeoutArgsPath = path.join(tempDir, "timeout-args.txt");
|
||||
const redactorPath = path.join(tempDir, "redactor.mjs");
|
||||
fs.writeFileSync(
|
||||
redactorPath,
|
||||
"export const redactSensitiveText = (value) => value;\n",
|
||||
"utf8",
|
||||
);
|
||||
writeFakeTimeout(path.join(tempDir, "timeout"), true);
|
||||
writeBashExecutable(path.join(tempDir, "fixture-command"), [
|
||||
'printf "DO_NOT_PRINT_OLD_COMMAND_LOG\\n"',
|
||||
@@ -893,6 +905,7 @@ exit 1
|
||||
OPENCLAW_E2E_COMMAND_TIMEOUT: "17s",
|
||||
OPENCLAW_E2E_LOG_DIR: logDir,
|
||||
OPENCLAW_E2E_LOG_TAIL_BYTES: "80",
|
||||
OPENCLAW_E2E_REDACTOR_MODULE: redactorPath,
|
||||
OPENCLAW_TEST_TIMEOUT_ARGS: timeoutArgsPath,
|
||||
},
|
||||
undefined,
|
||||
@@ -909,6 +922,38 @@ exit 1
|
||||
});
|
||||
});
|
||||
|
||||
it("redacts logged command failures before replay", () => {
|
||||
withTempDir("openclaw-e2e-instance-run-log-redact-", (tempDir) => {
|
||||
const redactorPath = path.join(tempDir, "redactor.mjs");
|
||||
fs.writeFileSync(
|
||||
redactorPath,
|
||||
'export const redactSensitiveText = (value) => value.replaceAll("fixture-secret", "***");\n',
|
||||
"utf8",
|
||||
);
|
||||
writeFakeTimeout(path.join(tempDir, "timeout"), true);
|
||||
writeBashExecutable(path.join(tempDir, "fixture-command"), [
|
||||
'printf "actionable failure fixture-secret\\n"',
|
||||
"exit 23",
|
||||
]);
|
||||
|
||||
const result = runBashWithHelper(
|
||||
["openclaw_e2e_run_logged redacted-failure fixture-command"],
|
||||
{
|
||||
PATH: `${tempDir}${path.delimiter}${hostPath}`,
|
||||
OPENCLAW_E2E_LOG_DIR: path.join(tempDir, "logs"),
|
||||
OPENCLAW_E2E_REDACTOR_MODULE: redactorPath,
|
||||
OPENCLAW_TEST_TIMEOUT_ARGS: path.join(tempDir, "timeout-args.txt"),
|
||||
},
|
||||
undefined,
|
||||
"; ",
|
||||
);
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toContain("actionable failure ***");
|
||||
expect(result.stdout).not.toContain("fixture-secret");
|
||||
});
|
||||
});
|
||||
|
||||
it("installs the trash shim under isolated test state", () => {
|
||||
withTempDir("openclaw-e2e-trash-shim-", (tempDir) => {
|
||||
const homeDir = path.join(tempDir, "home");
|
||||
|
||||
Reference in New Issue
Block a user