mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 21:21:10 +00:00
test: debrand pairing and dm policy fixtures
This commit is contained in:
@@ -31,7 +31,7 @@ describe("cron service store seam coverage", () => {
|
||||
sessionTarget: "current",
|
||||
wakeMode: "next-heartbeat",
|
||||
message: "legacy message-only payload",
|
||||
provider: "telegram",
|
||||
provider: "demo-channel",
|
||||
to: "123",
|
||||
deliver: true,
|
||||
state: {},
|
||||
@@ -68,7 +68,7 @@ describe("cron service store seam coverage", () => {
|
||||
}
|
||||
expect(job?.delivery).toMatchObject({
|
||||
mode: "announce",
|
||||
channel: "telegram",
|
||||
channel: "demo-channel",
|
||||
to: "123",
|
||||
});
|
||||
expect(job?.state.nextRunAtMs).toBe(now);
|
||||
@@ -87,7 +87,7 @@ describe("cron service store seam coverage", () => {
|
||||
});
|
||||
expect(persistedJob?.delivery).toMatchObject({
|
||||
mode: "announce",
|
||||
channel: "telegram",
|
||||
channel: "demo-channel",
|
||||
to: "123",
|
||||
});
|
||||
|
||||
|
||||
@@ -164,12 +164,12 @@ describe("pairing store", () => {
|
||||
it("reuses pending code and reports created=false", async () => {
|
||||
await withTempStateDir(async () => {
|
||||
const first = await upsertChannelPairingRequest({
|
||||
channel: "discord",
|
||||
channel: "demo-pairing-a",
|
||||
id: "u1",
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
const second = await upsertChannelPairingRequest({
|
||||
channel: "discord",
|
||||
channel: "demo-pairing-a",
|
||||
id: "u1",
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
@@ -177,7 +177,7 @@ describe("pairing store", () => {
|
||||
expect(second.created).toBe(false);
|
||||
expect(second.code).toBe(first.code);
|
||||
|
||||
const list = await listChannelPairingRequests("discord");
|
||||
const list = await listChannelPairingRequests("demo-pairing-a");
|
||||
expect(list).toHaveLength(1);
|
||||
expect(list[0]?.code).toBe(first.code);
|
||||
});
|
||||
@@ -186,13 +186,13 @@ describe("pairing store", () => {
|
||||
it("expires pending requests after TTL", async () => {
|
||||
await withTempStateDir(async (stateDir) => {
|
||||
const created = await upsertChannelPairingRequest({
|
||||
channel: "signal",
|
||||
channel: "demo-pairing-b",
|
||||
id: "+15550001111",
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
expect(created.created).toBe(true);
|
||||
|
||||
const filePath = resolvePairingFilePath(stateDir, "signal");
|
||||
const filePath = resolvePairingFilePath(stateDir, "demo-pairing-b");
|
||||
const raw = await fs.readFile(filePath, "utf8");
|
||||
const parsed = JSON.parse(raw) as {
|
||||
requests?: Array<Record<string, unknown>>;
|
||||
@@ -205,11 +205,11 @@ describe("pairing store", () => {
|
||||
}));
|
||||
await writeJsonFixture(filePath, { version: 1, requests });
|
||||
|
||||
const list = await listChannelPairingRequests("signal");
|
||||
const list = await listChannelPairingRequests("demo-pairing-b");
|
||||
expect(list).toHaveLength(0);
|
||||
|
||||
const next = await upsertChannelPairingRequest({
|
||||
channel: "signal",
|
||||
channel: "demo-pairing-b",
|
||||
id: "+15550001111",
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
@@ -253,7 +253,7 @@ describe("pairing store", () => {
|
||||
const ids = ["+15550000001", "+15550000002", "+15550000003"];
|
||||
for (const id of ids) {
|
||||
const created = await upsertChannelPairingRequest({
|
||||
channel: "whatsapp",
|
||||
channel: "demo-pairing-c",
|
||||
id,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
@@ -261,13 +261,13 @@ describe("pairing store", () => {
|
||||
}
|
||||
|
||||
const blocked = await upsertChannelPairingRequest({
|
||||
channel: "whatsapp",
|
||||
channel: "demo-pairing-c",
|
||||
id: "+15550000004",
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
});
|
||||
expect(blocked.created).toBe(false);
|
||||
|
||||
const list = await listChannelPairingRequests("whatsapp");
|
||||
const list = await listChannelPairingRequests("demo-pairing-c");
|
||||
const listIds = list.map((entry) => entry.id);
|
||||
expect(listIds).toHaveLength(3);
|
||||
expect(listIds).toContain("+15550000001");
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("security/dm-policy-shared", () => {
|
||||
|
||||
it("normalizes config + store allow entries and counts distinct senders", async () => {
|
||||
const state = await resolveDmAllowState({
|
||||
provider: "telegram",
|
||||
provider: "demo-channel-a" as never,
|
||||
accountId: "default",
|
||||
allowFrom: [" * ", " alice ", "ALICE", "bob"],
|
||||
normalizeEntry: (value) => value.toLowerCase(),
|
||||
@@ -70,7 +70,7 @@ describe("security/dm-policy-shared", () => {
|
||||
|
||||
it("handles empty allowlists and store failures", async () => {
|
||||
const state = await resolveDmAllowState({
|
||||
provider: "slack",
|
||||
provider: "demo-channel-b" as never,
|
||||
accountId: "default",
|
||||
allowFrom: undefined,
|
||||
readStore: async (_provider, _accountId) => {
|
||||
@@ -85,7 +85,7 @@ describe("security/dm-policy-shared", () => {
|
||||
|
||||
it("skips pairing-store reads when dmPolicy is allowlist", async () => {
|
||||
await expectStoreReadSkipped({
|
||||
provider: "telegram",
|
||||
provider: "demo-channel-a",
|
||||
accountId: "default",
|
||||
dmPolicy: "allowlist",
|
||||
});
|
||||
@@ -93,7 +93,7 @@ describe("security/dm-policy-shared", () => {
|
||||
|
||||
it("skips pairing-store reads when shouldRead=false", async () => {
|
||||
await expectStoreReadSkipped({
|
||||
provider: "slack",
|
||||
provider: "demo-channel-b",
|
||||
accountId: "default",
|
||||
shouldRead: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user