Merge 82dbdd0f763b66a0fdda6e903995e65cca09acfc into 598f1826d8b2bc969aace2c6459824737667218c

This commit is contained in:
Jackal Xin 2026-03-20 23:42:27 -04:00 committed by GitHub
commit 7e60f9ae9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 119 additions and 2 deletions

View File

@ -129,3 +129,116 @@ describe("linePlugin gateway.startAccount", () => {
await task;
});
});
describe("linePlugin status", () => {
it("does not report missing token or secret when snapshot came from file-backed config", async () => {
const snapshot = await linePlugin.status?.buildAccountSnapshot?.({
account: {
accountId: "default",
name: "Default",
enabled: true,
channelAccessToken: "token-from-file",
channelSecret: "secret-from-file",
tokenSource: "file",
config: {} as ResolvedLineAccount["config"],
} as never,
cfg: {} as OpenClawConfig,
runtime: undefined,
probe: undefined,
audit: undefined,
});
expect(snapshot?.configured).toBe(true);
expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([]);
});
it("keeps per-field warnings when only one credential is missing", async () => {
const snapshot = await linePlugin.status?.buildAccountSnapshot?.({
account: {
accountId: "default",
name: "Default",
enabled: true,
channelAccessToken: " ",
channelSecret: "secret-from-file",
tokenSource: "file",
config: {} as ResolvedLineAccount["config"],
} as never,
cfg: {} as OpenClawConfig,
runtime: undefined,
probe: undefined,
audit: undefined,
});
expect(snapshot?.configured).toBe(false);
expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel access token not configured",
},
]);
});
it("keeps per-field warnings when only the channel secret is missing", async () => {
const snapshot = await linePlugin.status?.buildAccountSnapshot?.({
account: {
accountId: "default",
name: "Default",
enabled: true,
channelAccessToken: "token-from-file",
channelSecret: " ",
tokenSource: "file",
config: {} as ResolvedLineAccount["config"],
} as never,
cfg: {} as OpenClawConfig,
runtime: undefined,
probe: undefined,
audit: undefined,
});
expect(snapshot?.configured).toBe(false);
expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel secret not configured",
},
]);
});
it("reports both warnings when both file-backed credentials are missing", async () => {
const snapshot = await linePlugin.status?.buildAccountSnapshot?.({
account: {
accountId: "default",
name: "Default",
enabled: true,
channelAccessToken: " ",
channelSecret: " ",
tokenSource: "file",
config: {} as ResolvedLineAccount["config"],
} as never,
cfg: {} as OpenClawConfig,
runtime: undefined,
probe: undefined,
audit: undefined,
});
expect(snapshot?.configured).toBe(false);
expect(linePlugin.status?.collectStatusIssues?.([snapshot as never])).toEqual([
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel access token not configured",
},
{
channel: "line",
accountId: "default",
kind: "config",
message: "LINE channel secret not configured",
},
]);
});
});

View File

@ -335,7 +335,7 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
const issues: ChannelStatusIssue[] = [];
for (const account of accounts) {
const accountId = account.accountId ?? DEFAULT_ACCOUNT_ID;
if (!account.channelAccessToken?.trim()) {
if (account.channelAccessTokenConfigured === false) {
issues.push({
channel: "line",
accountId,
@ -343,7 +343,7 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
message: "LINE channel access token not configured",
});
}
if (!account.channelSecret?.trim()) {
if (account.channelSecretConfigured === false) {
issues.push({
channel: "line",
accountId,
@ -371,6 +371,8 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
});
return {
...base,
channelAccessTokenConfigured: Boolean(account.channelAccessToken?.trim()),
channelSecretConfigured: Boolean(account.channelSecret?.trim()),
tokenSource: account.tokenSource,
mode: "webhook",
};

View File

@ -198,6 +198,8 @@ export type ChannelAccountSnapshot = {
profile?: unknown;
channelAccessToken?: string;
channelSecret?: string;
channelAccessTokenConfigured?: boolean;
channelSecretConfigured?: boolean;
};
export type ChannelLogSink = {