test: use synthetic approval pairing fixtures

This commit is contained in:
Peter Steinberger
2026-04-21 00:51:37 +01:00
parent 05835dd2d4
commit 71154bf3bf
3 changed files with 16 additions and 16 deletions

View File

@@ -24,7 +24,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "slack",
channel: "workspace",
senderId: "U123",
kind: "exec",
}),
@@ -49,7 +49,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "discord",
channel: "guildchat",
accountId: "work",
senderId: "123",
kind: "exec",
@@ -59,7 +59,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "discord",
channel: "guildchat",
accountId: "work",
senderId: "123",
kind: "plugin",
@@ -104,7 +104,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "slack",
channel: "workspace",
accountId: "work",
senderId: "U123",
kind: "exec",
@@ -121,7 +121,7 @@ describe("resolveApprovalCommandAuthorization", () => {
it("keeps empty approver fallback implicit without bypassing channel sender auth", () => {
getChannelPluginMock.mockReturnValue({
approvalCapability: createResolvedApproverActionAuthAdapter({
channelLabel: "Signal",
channelLabel: "QuietChat",
resolveApprovers: () => [],
}),
});
@@ -129,7 +129,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "signal",
channel: "quietchat",
accountId: "work",
senderId: "uuid:attacker",
kind: "exec",
@@ -140,7 +140,7 @@ describe("resolveApprovalCommandAuthorization", () => {
it("keeps configured approvers explicit when sender matches", () => {
getChannelPluginMock.mockReturnValue({
approvalCapability: createResolvedApproverActionAuthAdapter({
channelLabel: "Signal",
channelLabel: "QuietChat",
resolveApprovers: () => ["uuid:owner"],
}),
});
@@ -148,7 +148,7 @@ describe("resolveApprovalCommandAuthorization", () => {
expect(
resolveApprovalCommandAuthorization({
cfg: {} as never,
channel: "signal",
channel: "quietchat",
accountId: "work",
senderId: "uuid:owner",
kind: "exec",

View File

@@ -4,7 +4,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
const mocks = vi.hoisted(() => ({
resolveSessionAgentId: vi.fn(() => "agent-from-key"),
deliveryContextFromSession: vi.fn(() => ({
channel: "whatsapp",
channel: "mobilechat",
to: "+15550001",
accountId: "acct-1",
threadId: "thread-1",
@@ -101,7 +101,7 @@ describe("deliverSessionMaintenanceWarning", () => {
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
expect.objectContaining({
channel: "whatsapp",
channel: "mobilechat",
to: "+15550001",
session: { key: "agent:main:main", agentId: "agent-from-key" },
}),

View File

@@ -4,9 +4,9 @@ import { issuePairingChallenge } from "./pairing-challenge.js";
describe("issuePairingChallenge", () => {
function createBaseChallengeParams() {
return {
channel: "telegram",
channel: "forum",
senderId: "123",
senderIdLine: "Your Telegram user id: 123",
senderIdLine: "Your forum user id: 123",
} as const;
}
@@ -114,9 +114,9 @@ describe("issuePairingChallenge", () => {
const upsert = vi.fn(async () => ({ code: "1111", created: true }));
return {
issueParams: {
channel: "discord",
channel: "guildchat",
senderId: "42",
senderIdLine: "Your Discord user id: 42",
senderIdLine: "Your guildchat user id: 42",
meta: { name: "alice" },
upsertPairingRequest: upsert,
onCreated,
@@ -136,9 +136,9 @@ describe("issuePairingChallenge", () => {
const onReplyError = vi.fn();
return {
issueParams: {
channel: "signal",
channel: "quietchat",
senderId: "+1555",
senderIdLine: "Your Signal sender id: +1555",
senderIdLine: "Your quietchat sender id: +1555",
upsertPairingRequest: async () => ({ code: "9999", created: true }),
onReplyError,
},