@@ -379,6 +379,64 @@ describe("gateway send mirroring", () => {
379379 expect ( response ?. [ 0 ] ) . toBe ( true ) ;
380380 } ) ;
381381
382+ it ( "uses the resolved runtime config for gateway sends when Feishu appSecret is SecretRef-backed" , async ( ) => {
383+ const sourceConfig = {
384+ channels : {
385+ feishu : {
386+ appId : "cli_source" ,
387+ appSecret : {
388+ source : "env" ,
389+ provider : "default" ,
390+ id : "FEISHU_APP_SECRET" ,
391+ } ,
392+ } ,
393+ } ,
394+ } ;
395+ const runtimeConfig = {
396+ channels : {
397+ feishu : {
398+ appId : "cli_source" ,
399+ appSecret : "resolved-feishu-secret" ,
400+ } ,
401+ } ,
402+ } ;
403+ mocks . applyPluginAutoEnable . mockImplementation ( ( { config } ) => ( {
404+ config,
405+ changes : [ ] ,
406+ autoEnabledReasons : { } ,
407+ } ) ) ;
408+ mocks . getRuntimeConfigSnapshot . mockReturnValue ( runtimeConfig ) ;
409+ mocks . getRuntimeConfigSourceSnapshot . mockReturnValue ( sourceConfig ) ;
410+ mocks . deliverOutboundPayloads . mockResolvedValue ( [
411+ { messageId : "feishu-media" , channel : "feishu" } ,
412+ ] ) ;
413+
414+ const context = {
415+ ...makeContext ( ) ,
416+ getRuntimeConfig : ( ) => sourceConfig ,
417+ } as unknown as GatewayRequestContext ;
418+ const respond = vi . fn ( ) ;
419+ await sendHandlers . send ( {
420+ params : {
421+ channel : "feishu" ,
422+ to : "chat:oc_target" ,
423+ mediaUrl : "https://example.com/image.png" ,
424+ idempotencyKey : "idem-feishu-runtime-config" ,
425+ } as never ,
426+ respond,
427+ context,
428+ req : { type : "req" , id : "1" , method : "send" } ,
429+ client : null as never ,
430+ isWebchatConnect : ( ) => false ,
431+ } ) ;
432+
433+ expect ( deliveryCall ( ) ?. cfg ) . toBe ( runtimeConfig ) ;
434+ expect ( JSON . stringify ( deliveryCall ( ) ?. cfg ) ) . toContain ( "resolved-feishu-secret" ) ;
435+ expect ( JSON . stringify ( deliveryCall ( ) ?. cfg ) ) . not . toContain ( "FEISHU_APP_SECRET" ) ;
436+ const response = firstRespondCall ( respond ) ;
437+ expect ( response ?. [ 0 ] ) . toBe ( true ) ;
438+ } ) ;
439+
382440 it ( "matches message.action runtime config against the canonical pre-auto-enable source config" , async ( ) => {
383441 const sourceConfig = {
384442 channels : {
@@ -549,18 +607,19 @@ describe("gateway send mirroring", () => {
549607 expect ( lastDispatchChannelMessageActionCall ( ) ?. cfg ) . toBe ( autoEnabledRequestConfig ) ;
550608 } ) ;
551609
552- it ( "does not read the runtime config snapshot for send requests" , async ( ) => {
553- mockDeliverySuccess ( "m-no- runtime-config-read " ) ;
610+ it ( "checks the runtime config snapshot for send requests" , async ( ) => {
611+ mockDeliverySuccess ( "m-runtime-config-checked " ) ;
554612
555613 await runSend ( {
556614 to : "channel:C1" ,
557615 message : "hi" ,
558616 channel : "slack" ,
559- idempotencyKey : "idem-send-no- runtime-config-read " ,
617+ idempotencyKey : "idem-send-runtime-config-checked " ,
560618 } ) ;
561619
562- expect ( mocks . getRuntimeConfigSnapshot ) . not . toHaveBeenCalled ( ) ;
563- expect ( mocks . getRuntimeConfigSourceSnapshot ) . not . toHaveBeenCalled ( ) ;
620+ expect ( mocks . getRuntimeConfigSnapshot ) . toHaveBeenCalledTimes ( 1 ) ;
621+ expect ( mocks . getRuntimeConfigSourceSnapshot ) . toHaveBeenCalledTimes ( 1 ) ;
622+ expect ( deliveryCall ( ) ?. cfg ) . toEqual ( { } ) ;
564623 } ) ;
565624
566625 it ( "dedupes concurrent message.action requests while inflight" , async ( ) => {
0 commit comments