@@ -43,6 +43,47 @@ describe('RemoteSessionManager', () => {
4343 ] ) ;
4444 } ) ;
4545
46+ it ( 'executes authenticated no-response mouse movement without sending an ack' , async ( ) => {
47+ const handled : MouseMoveCommand [ ] = [ ] ;
48+ const manager = createManager ( {
49+ onCommand : ( command ) => {
50+ handled . push ( command as MouseMoveCommand ) ;
51+ return { ok : true } ;
52+ }
53+ } ) ;
54+ const connection = createConnection ( ) ;
55+ manager . addConnection ( connection ) ;
56+ const command = createMouseMoveCommand ( { responseMode : 'none' } ) ;
57+
58+ await manager . handleMessage ( connection . id , JSON . stringify ( command ) ) ;
59+
60+ expect ( sentResponses ( connection ) ) . toEqual ( [ ] ) ;
61+ expect ( handled ) . toEqual ( [ command ] ) ;
62+ expect ( manager . getAuthenticatedClients ( ) ) . toEqual ( [
63+ expect . objectContaining ( {
64+ id : connection . id ,
65+ deviceId : 'android-1' ,
66+ transport : 'bluetooth'
67+ } )
68+ ] ) ;
69+ } ) ;
70+
71+ it ( 'suppresses adapter failure responses for no-response mouse movement' , async ( ) => {
72+ const onError = vi . fn ( ) ;
73+ const manager = createManager ( {
74+ onError,
75+ onCommand : ( ) => ( { ok : false , code : 'adapter_failure' , message : 'Move failed.' } )
76+ } ) ;
77+ const connection = createConnection ( ) ;
78+ manager . addConnection ( connection ) ;
79+ const command = createMouseMoveCommand ( { responseMode : 'none' } ) ;
80+
81+ await manager . handleMessage ( connection . id , JSON . stringify ( command ) ) ;
82+
83+ expect ( sentResponses ( connection ) ) . toEqual ( [ ] ) ;
84+ expect ( onError ) . toHaveBeenCalledWith ( 'Move failed.' ) ;
85+ } ) ;
86+
4687 it ( 'acks authenticated heartbeat pings without executing desktop commands' , async ( ) => {
4788 const onCommand = vi . fn ( ) ;
4889 const manager = createManager ( { onCommand } ) ;
@@ -81,6 +122,46 @@ describe('RemoteSessionManager', () => {
81122 expect ( onCommand ) . not . toHaveBeenCalled ( ) ;
82123 } ) ;
83124
125+ it ( 'rejects unauthenticated no-response movement with a structured auth error' , async ( ) => {
126+ const onCommand = vi . fn ( ) ;
127+ const manager = createManager ( { onCommand } ) ;
128+ const connection = createConnection ( ) ;
129+ manager . addConnection ( connection ) ;
130+
131+ await manager . handleMessage (
132+ connection . id ,
133+ JSON . stringify ( createMouseMoveCommand ( { auth : 'invalid' , responseMode : 'none' } ) )
134+ ) ;
135+
136+ expect ( sentResponses ( connection ) ) . toEqual ( [
137+ expect . objectContaining ( {
138+ type : 'error' ,
139+ ok : false ,
140+ error : expect . objectContaining ( { code : 'invalid_auth' } )
141+ } )
142+ ] ) ;
143+ expect ( onCommand ) . not . toHaveBeenCalled ( ) ;
144+ } ) ;
145+
146+ it ( 'rejects unsupported no-response command types during validation' , async ( ) => {
147+ const onCommand = vi . fn ( ) ;
148+ const manager = createManager ( { onCommand } ) ;
149+ const connection = createConnection ( ) ;
150+ manager . addConnection ( connection ) ;
151+ const command = createPingCommand ( { responseMode : 'none' } as Partial < PingCommand > ) ;
152+
153+ await manager . handleMessage ( connection . id , JSON . stringify ( command ) ) ;
154+
155+ expect ( sentResponses ( connection ) ) . toEqual ( [
156+ expect . objectContaining ( {
157+ type : 'error' ,
158+ ok : false ,
159+ error : expect . objectContaining ( { code : 'invalid_payload' } )
160+ } )
161+ ] ) ;
162+ expect ( onCommand ) . not . toHaveBeenCalled ( ) ;
163+ } ) ;
164+
84165 it ( 'keeps pairing requests pending until they are accepted' , async ( ) => {
85166 const store = new MemoryPairingStore ( { desktopId : 'desktop-1' , pairedDevices : [ ] } ) ;
86167 const approvalManager = new PairingApprovalManager ( store , ( ) => now ) ;
0 commit comments