@@ -440,37 +440,33 @@ describe("active-memory plugin", () => {
440440 expect ( runEmbeddedPiAgent ) . toHaveBeenCalledTimes ( 1 ) ;
441441 } ) ;
442442
443- it ( "blocks write-scoped gateway callers from changing global active-memory config" , async ( ) => {
443+ it ( "blocks gateway callers without admin scope from changing global active-memory config" , async ( ) => {
444444 const command = registeredCommands [ "active-memory" ] ;
445445
446- const offResult = await command . handler ( {
447- channel : "gateway" ,
448- isAuthorizedSender : true ,
449- gatewayClientScopes : [ "operator.write" ] ,
450- args : "off --global" ,
451- commandBody : "/active-memory off --global" ,
452- config : { } ,
453- requestConversationBinding : async ( ) => ( { status : "error" , message : "unsupported" } ) ,
454- detachConversationBinding : async ( ) => ( { removed : false } ) ,
455- getCurrentConversationBinding : async ( ) => null ,
456- } ) ;
457-
458- expect ( offResult . text ) . toContain ( "requires operator.admin" ) ;
459- expect ( api . runtime . config . replaceConfigFile ) . not . toHaveBeenCalled ( ) ;
446+ for ( const { args, gatewayClientScopes } of [
447+ { args : "off --global" , gatewayClientScopes : [ "operator.write" ] } ,
448+ { args : "on --global" , gatewayClientScopes : [ "operator.write" ] } ,
449+ { args : "disable --global" , gatewayClientScopes : [ "operator.write" ] } ,
450+ { args : "enable --global" , gatewayClientScopes : [ "operator.write" ] } ,
451+ { args : "disabled --global" , gatewayClientScopes : [ "operator.write" ] } ,
452+ { args : "enabled --global" , gatewayClientScopes : [ "operator.write" ] } ,
453+ { args : "off --global" , gatewayClientScopes : [ ] } ,
454+ ] ) {
455+ const result = await command . handler ( {
456+ channel : "gateway" ,
457+ isAuthorizedSender : true ,
458+ gatewayClientScopes,
459+ args,
460+ commandBody : `/active-memory ${ args } ` ,
461+ config : { } ,
462+ requestConversationBinding : async ( ) => ( { status : "error" , message : "unsupported" } ) ,
463+ detachConversationBinding : async ( ) => ( { removed : false } ) ,
464+ getCurrentConversationBinding : async ( ) => null ,
465+ } ) ;
460466
461- const onResult = await command . handler ( {
462- channel : "gateway" ,
463- isAuthorizedSender : true ,
464- gatewayClientScopes : [ "operator.write" ] ,
465- args : "on --global" ,
466- commandBody : "/active-memory on --global" ,
467- config : { } ,
468- requestConversationBinding : async ( ) => ( { status : "error" , message : "unsupported" } ) ,
469- detachConversationBinding : async ( ) => ( { removed : false } ) ,
470- getCurrentConversationBinding : async ( ) => null ,
471- } ) ;
467+ expect ( result . text ) . toContain ( "global enable/disable changes require operator.admin" ) ;
468+ }
472469
473- expect ( onResult . text ) . toContain ( "requires operator.admin" ) ;
474470 expect ( api . runtime . config . replaceConfigFile ) . not . toHaveBeenCalled ( ) ;
475471 } ) ;
476472
0 commit comments