mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 01:50:43 +00:00
test: tighten googlechat pairing timestamp
This commit is contained in:
@@ -127,6 +127,7 @@ describe("googlechat inbound access policy", () => {
|
||||
|
||||
it("issues a pairing challenge for unauthorized DMs in pairing mode", async () => {
|
||||
primeCommonDefaults();
|
||||
const now = new Date("2026-05-09T06:35:00.000Z").getTime();
|
||||
const issueChallenge = vi.fn(async ({ onCreated, sendPairingReply }) => {
|
||||
onCreated?.();
|
||||
await sendPairingReply("pairing text");
|
||||
@@ -146,41 +147,45 @@ describe("googlechat inbound access policy", () => {
|
||||
const statusSink = vi.fn();
|
||||
const logVerbose = vi.fn();
|
||||
|
||||
await expect(
|
||||
applyGoogleChatInboundAccessPolicy({
|
||||
account: {
|
||||
accountId: "default",
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(now);
|
||||
try {
|
||||
await expect(
|
||||
applyGoogleChatInboundAccessPolicy({
|
||||
account: {
|
||||
accountId: "default",
|
||||
config: {
|
||||
dm: { policy: "pairing" },
|
||||
},
|
||||
} as never,
|
||||
config: {
|
||||
dm: { policy: "pairing" },
|
||||
},
|
||||
} as never,
|
||||
config: {
|
||||
channels: { googlechat: {} },
|
||||
} as never,
|
||||
core: createCore() as never,
|
||||
space: { name: "spaces/AAA", displayName: "DM" } as never,
|
||||
message: { annotations: [] } as never,
|
||||
isGroup: false,
|
||||
senderId: "users/abc",
|
||||
senderName: "Alice",
|
||||
senderEmail: "alice@example.com",
|
||||
rawBody: "hello",
|
||||
statusSink,
|
||||
logVerbose,
|
||||
}),
|
||||
).resolves.toEqual({ ok: false });
|
||||
channels: { googlechat: {} },
|
||||
} as never,
|
||||
core: createCore() as never,
|
||||
space: { name: "spaces/AAA", displayName: "DM" } as never,
|
||||
message: { annotations: [] } as never,
|
||||
isGroup: false,
|
||||
senderId: "users/abc",
|
||||
senderName: "Alice",
|
||||
senderEmail: "alice@example.com",
|
||||
rawBody: "hello",
|
||||
statusSink,
|
||||
logVerbose,
|
||||
}),
|
||||
).resolves.toEqual({ ok: false });
|
||||
|
||||
expect(issueChallenge).toHaveBeenCalledTimes(1);
|
||||
expect(sendGoogleChatMessage).toHaveBeenCalledWith({
|
||||
account: expect.anything(),
|
||||
space: "spaces/AAA",
|
||||
text: "pairing text",
|
||||
});
|
||||
expect(statusSink).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
lastOutboundAt: expect.any(Number),
|
||||
}),
|
||||
);
|
||||
expect(issueChallenge).toHaveBeenCalledTimes(1);
|
||||
expect(sendGoogleChatMessage).toHaveBeenCalledWith({
|
||||
account: expect.anything(),
|
||||
space: "spaces/AAA",
|
||||
text: "pairing text",
|
||||
});
|
||||
expect(statusSink).toHaveBeenCalledWith({
|
||||
lastOutboundAt: now,
|
||||
});
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("allows group traffic when sender and mention gates pass", async () => {
|
||||
|
||||
Reference in New Issue
Block a user