@@ -70,6 +70,7 @@ type ApprovedPairingDevice = ApprovedPairingResult["device"];
7070const INTERNAL_PAIRING_SCOPES = [ "operator.write" , "operator.pairing" ] ;
7171
7272function createApi ( params ?: {
73+ config ?: OpenClawPluginApi [ "config" ] ;
7374 runtime ?: OpenClawPluginApi [ "runtime" ] ;
7475 pluginConfig ?: Record < string , unknown > ;
7576 registerCommand ?: ( command : OpenClawPluginCommandDefinition ) => void ;
@@ -78,7 +79,7 @@ function createApi(params?: {
7879 id : "device-pair" ,
7980 name : "device-pair" ,
8081 source : "test" ,
81- config : {
82+ config : params ?. config ?? {
8283 gateway : {
8384 auth : {
8485 mode : "token" ,
@@ -96,6 +97,7 @@ function createApi(params?: {
9697}
9798
9899function registerPairCommand ( params ?: {
100+ config ?: OpenClawPluginApi [ "config" ] ;
99101 runtime ?: OpenClawPluginApi [ "runtime" ] ;
100102 pluginConfig ?: Record < string , unknown > ;
101103} ) : OpenClawPluginCommandDefinition {
@@ -649,6 +651,36 @@ describe("device-pair /pair default setup code", () => {
649651 expect ( result ) . toEqual ( { text : "Error: Configured publicUrl is invalid." } ) ;
650652 } ) ;
651653
654+ it ( "rejects invalid gateway.remote.url before falling back to bind-derived setup urls" , async ( ) => {
655+ const command = registerPairCommand ( {
656+ config : {
657+ gateway : {
658+ bind : "custom" ,
659+ customBindHost : "127.0.0.1" ,
660+ remote : { url : "http://localhost:notaport" } ,
661+ auth : {
662+ mode : "token" ,
663+ token : "gateway-token" ,
664+ } ,
665+ } ,
666+ } ,
667+ pluginConfig : {
668+ publicUrl : undefined ,
669+ } ,
670+ } ) ;
671+ const result = await command . handler (
672+ createCommandContext ( {
673+ channel : "webchat" ,
674+ args : "" ,
675+ commandBody : "/pair" ,
676+ gatewayClientScopes : [ "operator.write" , "operator.pairing" ] ,
677+ } ) ,
678+ ) ;
679+
680+ expect ( pluginApiMocks . issueDeviceBootstrapToken ) . not . toHaveBeenCalled ( ) ;
681+ expect ( result ) . toEqual ( { text : "Error: Configured gateway.remote.url is invalid." } ) ;
682+ } ) ;
683+
652684 it . each ( [
653685 "http://localhost:notaport" ,
654686 "http:gateway.example.test" ,
0 commit comments