mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 00:12:54 +00:00
QQBot fallback approval buttons now reuse the same slash-command authorization path as real commands, including access groups and default-account config merging.
Verification:
- node scripts/test-extension.mjs qqbot
- node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check && git diff --check
- pnpm lint --threads=8
- node scripts/run-vitest.mjs src/agents/agent-command.live-model-switch.test.ts
- GitHub PR checks for 7cc0f15031: passed
Thanks @eleqtrizit.
Co-authored-by: Agustin Rivera <agustin@rivera-web.com>
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { isImplicitSameChatApprovalAuthorization } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { registerPlatformAdapter, type PlatformAdapter } from "./engine/adapter/index.js";
|
|
import { authorizeQQBotApprovalAction } from "./exec-approvals.js";
|
|
|
|
describe("authorizeQQBotApprovalAction", () => {
|
|
beforeEach(() => {
|
|
registerPlatformAdapter({
|
|
validateRemoteUrl: vi.fn(async () => undefined),
|
|
resolveSecret: vi.fn(async (value: unknown) =>
|
|
typeof value === "string" ? value : undefined,
|
|
),
|
|
downloadFile: vi.fn(async () => "/tmp/file"),
|
|
fetchMedia: vi.fn(async () => {
|
|
throw new Error("unused");
|
|
}),
|
|
getTempDir: () => "/tmp",
|
|
hasConfiguredSecret: (value: unknown) => typeof value === "string" && value.length > 0,
|
|
normalizeSecretInputString: (value: unknown) =>
|
|
typeof value === "string" ? value : undefined,
|
|
resolveSecretInputString: ({ value }: { value: unknown }) =>
|
|
typeof value === "string" ? value : undefined,
|
|
} as PlatformAdapter);
|
|
});
|
|
|
|
it("marks unconfigured exec approval fallback authorization as implicit", () => {
|
|
const result = authorizeQQBotApprovalAction({
|
|
cfg: {
|
|
channels: {
|
|
qqbot: {
|
|
appId: "app",
|
|
clientSecret: "secret",
|
|
},
|
|
},
|
|
} as OpenClawConfig,
|
|
accountId: "default",
|
|
senderId: "ATTACKER_OPENID",
|
|
approvalKind: "exec",
|
|
});
|
|
|
|
expect(result).toEqual({ authorized: true });
|
|
expect(isImplicitSameChatApprovalAuthorization(result)).toBe(true);
|
|
});
|
|
|
|
it("keeps configured approver authorization explicit", () => {
|
|
const result = authorizeQQBotApprovalAction({
|
|
cfg: {
|
|
channels: {
|
|
qqbot: {
|
|
appId: "app",
|
|
clientSecret: "secret",
|
|
execApprovals: {
|
|
enabled: true,
|
|
approvers: ["OWNER_OPENID"],
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig,
|
|
accountId: "default",
|
|
senderId: "OWNER_OPENID",
|
|
approvalKind: "exec",
|
|
});
|
|
|
|
expect(result).toEqual({ authorized: true });
|
|
expect(isImplicitSameChatApprovalAuthorization(result)).toBe(false);
|
|
});
|
|
});
|