@@ -3,12 +3,16 @@ import type { ChannelPlugin } from "../../channels/plugins/types.public.js";
33import type { OpenClawConfig } from "../../config/config.js" ;
44import type { ExecApprovalRequest } from "../../infra/exec-approvals.js" ;
55import { resetPluginRuntimeStateForTest , setActivePluginRegistry } from "../../plugins/runtime.js" ;
6+ import { MAX_DATE_TIMESTAMP_MS } from "../../shared/number-coercion.js" ;
67import {
78 createChannelTestPluginBase ,
89 createTestRegistry ,
910} from "../../test-utils/channel-plugins.js" ;
1011import type { MsgContext } from "../templating.js" ;
11- import { resolvePrivateCommandRouteTargets } from "./commands-private-route.js" ;
12+ import {
13+ resolvePrivateCommandApprovalRouteExpiresAtMs ,
14+ resolvePrivateCommandRouteTargets ,
15+ } from "./commands-private-route.js" ;
1216import type { HandleCommandsParams } from "./commands-types.js" ;
1317
1418function createApprovalChannelPlugin ( params : {
@@ -144,6 +148,22 @@ afterEach(() => {
144148 resetPluginRuntimeStateForTest ( ) ;
145149} ) ;
146150
151+ describe ( "resolvePrivateCommandApprovalRouteExpiresAtMs" , ( ) => {
152+ it ( "returns a bounded five-minute route expiry for valid clocks" , ( ) => {
153+ expect ( resolvePrivateCommandApprovalRouteExpiresAtMs ( 1_800_000_000_000 ) ) . toBe (
154+ 1_800_000_300_000 ,
155+ ) ;
156+ } ) ;
157+
158+ it ( "expires private command routes immediately for invalid clocks" , ( ) => {
159+ expect ( resolvePrivateCommandApprovalRouteExpiresAtMs ( Number . NaN ) ) . toBe ( 0 ) ;
160+ } ) ;
161+
162+ it ( "expires private command routes immediately when expiry would exceed Date bounds" , ( ) => {
163+ expect ( resolvePrivateCommandApprovalRouteExpiresAtMs ( MAX_DATE_TIMESTAMP_MS ) ) . toBe ( 0 ) ;
164+ } ) ;
165+ } ) ;
166+
147167describe ( "resolvePrivateCommandRouteTargets" , ( ) => {
148168 it ( "prefers a same-surface private owner route even when another owner route is listed first" , async ( ) => {
149169 registerApprovalChannelPlugins ( [
0 commit comments