mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:08:28 +00:00
Secrets: harden SecretRef-safe models.json persistence (#38955)
This commit is contained in:
@@ -150,10 +150,14 @@ function createMessage(params: {
|
||||
id: string;
|
||||
channelId: string;
|
||||
content: string;
|
||||
author: import("@buape/carbon").Message["author"];
|
||||
author: {
|
||||
id: string;
|
||||
bot: boolean;
|
||||
username?: string;
|
||||
};
|
||||
mentionedUsers?: Array<{ id: string }>;
|
||||
mentionedEveryone?: boolean;
|
||||
attachments?: import("@buape/carbon").Message["attachments"];
|
||||
attachments?: Array<Record<string, unknown>>;
|
||||
}): import("@buape/carbon").Message {
|
||||
return {
|
||||
id: params.id,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
const preflightDiscordMessageMock = vi.hoisted(() => vi.fn());
|
||||
const processDiscordMessageMock = vi.hoisted(() => vi.fn());
|
||||
const eventualReplyDeliveredMock = vi.hoisted(() => vi.fn());
|
||||
type SetStatusFn = (patch: Record<string, unknown>) => void;
|
||||
|
||||
vi.mock("./message-handler.preflight.js", () => ({
|
||||
preflightDiscordMessage: preflightDiscordMessageMock,
|
||||
@@ -45,7 +46,7 @@ function createPreflightContext(channelId = "ch-1") {
|
||||
}
|
||||
|
||||
async function createLifecycleStopScenario(params: {
|
||||
createHandler: (status: ReturnType<typeof vi.fn>) => {
|
||||
createHandler: (status: SetStatusFn) => {
|
||||
handler: (data: never, opts: never) => Promise<void>;
|
||||
stop: () => void;
|
||||
};
|
||||
@@ -59,7 +60,7 @@ async function createLifecycleStopScenario(params: {
|
||||
createPreflightContext(contextParams.data.channel_id),
|
||||
);
|
||||
|
||||
const setStatus = vi.fn();
|
||||
const setStatus = vi.fn<SetStatusFn>();
|
||||
const { handler, stop } = params.createHandler(setStatus);
|
||||
|
||||
await expect(handler(createMessageData("m-1") as never, {} as never)).resolves.toBeUndefined();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/types.js";
|
||||
import type { createDiscordMessageHandler } from "./message-handler.js";
|
||||
import { createNoopThreadBindingManager } from "./thread-bindings.js";
|
||||
|
||||
export const DEFAULT_DISCORD_BOT_USER_ID = "bot-123";
|
||||
@@ -9,7 +10,7 @@ export function createDiscordHandlerParams(overrides?: {
|
||||
setStatus?: (patch: Record<string, unknown>) => void;
|
||||
abortSignal?: AbortSignal;
|
||||
workerRunTimeoutMs?: number;
|
||||
}) {
|
||||
}): Parameters<typeof createDiscordMessageHandler>[0] {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
discord: {
|
||||
|
||||
Reference in New Issue
Block a user