mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 20:21:23 +00:00
refactor(test): dedupe channel and monitor action suites
This commit is contained in:
@@ -71,36 +71,48 @@ async function runRepair(cfg: OpenClawConfig) {
|
||||
await maybeRepairGatewayServiceConfig(cfg, "local", makeDoctorIo(), makeDoctorPrompts());
|
||||
}
|
||||
|
||||
const gatewayProgramArguments = [
|
||||
"/usr/bin/node",
|
||||
"/usr/local/bin/openclaw",
|
||||
"gateway",
|
||||
"--port",
|
||||
"18789",
|
||||
];
|
||||
|
||||
function setupGatewayTokenRepairScenario(expectedToken: string) {
|
||||
mocks.readCommand.mockResolvedValue({
|
||||
programArguments: gatewayProgramArguments,
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "stale-token",
|
||||
},
|
||||
});
|
||||
mocks.auditGatewayServiceConfig.mockResolvedValue({
|
||||
ok: false,
|
||||
issues: [
|
||||
{
|
||||
code: "gateway-token-mismatch",
|
||||
message: "Gateway service OPENCLAW_GATEWAY_TOKEN does not match gateway.auth.token",
|
||||
level: "recommended",
|
||||
},
|
||||
],
|
||||
});
|
||||
mocks.buildGatewayInstallPlan.mockResolvedValue({
|
||||
programArguments: gatewayProgramArguments,
|
||||
workingDirectory: "/tmp",
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: expectedToken,
|
||||
},
|
||||
});
|
||||
mocks.install.mockResolvedValue(undefined);
|
||||
}
|
||||
|
||||
describe("maybeRepairGatewayServiceConfig", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("treats gateway.auth.token as source of truth for service token repairs", async () => {
|
||||
mocks.readCommand.mockResolvedValue({
|
||||
programArguments: ["/usr/bin/node", "/usr/local/bin/openclaw", "gateway", "--port", "18789"],
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "stale-token",
|
||||
},
|
||||
});
|
||||
mocks.auditGatewayServiceConfig.mockResolvedValue({
|
||||
ok: false,
|
||||
issues: [
|
||||
{
|
||||
code: "gateway-token-mismatch",
|
||||
message: "Gateway service OPENCLAW_GATEWAY_TOKEN does not match gateway.auth.token",
|
||||
level: "recommended",
|
||||
},
|
||||
],
|
||||
});
|
||||
mocks.buildGatewayInstallPlan.mockResolvedValue({
|
||||
programArguments: ["/usr/bin/node", "/usr/local/bin/openclaw", "gateway", "--port", "18789"],
|
||||
workingDirectory: "/tmp",
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "config-token",
|
||||
},
|
||||
});
|
||||
mocks.install.mockResolvedValue(undefined);
|
||||
setupGatewayTokenRepairScenario("config-token");
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
gateway: {
|
||||
@@ -130,42 +142,7 @@ describe("maybeRepairGatewayServiceConfig", () => {
|
||||
const previousToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
process.env.OPENCLAW_GATEWAY_TOKEN = "env-token";
|
||||
try {
|
||||
mocks.readCommand.mockResolvedValue({
|
||||
programArguments: [
|
||||
"/usr/bin/node",
|
||||
"/usr/local/bin/openclaw",
|
||||
"gateway",
|
||||
"--port",
|
||||
"18789",
|
||||
],
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "stale-token",
|
||||
},
|
||||
});
|
||||
mocks.auditGatewayServiceConfig.mockResolvedValue({
|
||||
ok: false,
|
||||
issues: [
|
||||
{
|
||||
code: "gateway-token-mismatch",
|
||||
message: "Gateway service OPENCLAW_GATEWAY_TOKEN does not match gateway.auth.token",
|
||||
level: "recommended",
|
||||
},
|
||||
],
|
||||
});
|
||||
mocks.buildGatewayInstallPlan.mockResolvedValue({
|
||||
programArguments: [
|
||||
"/usr/bin/node",
|
||||
"/usr/local/bin/openclaw",
|
||||
"gateway",
|
||||
"--port",
|
||||
"18789",
|
||||
],
|
||||
workingDirectory: "/tmp",
|
||||
environment: {
|
||||
OPENCLAW_GATEWAY_TOKEN: "env-token",
|
||||
},
|
||||
});
|
||||
mocks.install.mockResolvedValue(undefined);
|
||||
setupGatewayTokenRepairScenario("env-token");
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
gateway: {},
|
||||
|
||||
Reference in New Issue
Block a user