Files
openclaw/src/plugin-sdk/channel-secret-basic-runtime.test.ts
Peter Steinberger 83bf0379c9 refactor(channels): share plugin contract scaffolds (#105838)
* refactor(channels): share plugin contract scaffolds

* fix: preserve channel config hint metadata

* chore: refresh Plugin SDK API baseline

* ci: refresh plugin SDK surface budget

* fix(ci): allow read-only state database boundary

* fix(ci): dedupe read-only state database boundary
2026-07-13 01:51:32 -07:00

66 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { createChannelSecretTargetRegistryEntries } from "./channel-secret-basic-runtime.js";
describe("createChannelSecretTargetRegistryEntries", () => {
it("builds account and channel SecretInput targets with fixed registry metadata", () => {
expect(
createChannelSecretTargetRegistryEntries({
channelKey: "example",
account: ["token"],
channel: ["token"],
}),
).toEqual([
{
id: "channels.example.accounts.*.token",
targetType: "channels.example.accounts.*.token",
configFile: "openclaw.json",
pathPattern: "channels.example.accounts.*.token",
secretShape: "secret_input",
expectedResolvedValue: "string",
includeInPlan: true,
includeInConfigure: true,
includeInAudit: true,
},
{
id: "channels.example.token",
targetType: "channels.example.token",
configFile: "openclaw.json",
pathPattern: "channels.example.token",
secretShape: "secret_input",
expectedResolvedValue: "string",
includeInPlan: true,
includeInConfigure: true,
includeInAudit: true,
},
]);
});
it("supports sibling refs and CLI target aliases", () => {
expect(
createChannelSecretTargetRegistryEntries({
channelKey: "example",
account: [
{
path: "credentials",
refPath: "credentialsRef",
targetType: "channels.example.credentials",
targetTypeAliases: ["channels.example.accounts.*.credentials"],
secretShape: "sibling_ref",
expectedResolvedValue: "string-or-object",
accountIdPathSegmentIndex: 3,
},
],
})[0],
).toMatchObject({
id: "channels.example.accounts.*.credentials",
targetType: "channels.example.credentials",
targetTypeAliases: ["channels.example.accounts.*.credentials"],
pathPattern: "channels.example.accounts.*.credentials",
refPathPattern: "channels.example.accounts.*.credentialsRef",
secretShape: "sibling_ref",
expectedResolvedValue: "string-or-object",
accountIdPathSegmentIndex: 3,
});
});
});