Skip to content

Commit 4d7a902

Browse files
committed
test(android): reach the server rule through the provider-forwarding branch
A `-P` of `9_999` parses to no port at all, so the pair stayed an unowned global and the older host-global refusal answered the call before the server rule ever saw it: the assertion passed without reaching the check it was written to pin. The port now parses, the assertion names the server refusal, and a port naming the server this lease holds is pinned on the same branch as what the provider is handed. Removing the server check from `requireManagedAndroidAdbAddressing` now fails four tests across the provider branch, the device route, the reachability run, and the root host.
1 parent 39654f9 commit 4d7a902

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

packages/platform-android/src/adb-provider-scope.test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,37 @@ test('a managed port scope refuses global options the provider cannot restate',
172172
).rejects.toMatchObject({ details: { reason: 'managed-device-transport-mismatch' } });
173173
expect(providerCalls).toEqual([]);
174174

175-
// A port typed into argv is the same conflict as one naming another target: the provider would
176-
// hand the caller's `-P` to an adb it does not address, so the call is refused here.
175+
// A port typed into argv names a server the provider cannot address, so the server rule refuses
176+
// it here — not the host-global rule, which is why the port has to parse.
177177
providerCalls.length = 0;
178178
await expect(
179179
capture({ serial: DEVICE.id, serverPort: 15_037 }, [
180180
'-P',
181-
'9_999',
181+
'9999',
182182
'-s',
183183
DEVICE.id,
184184
'shell',
185185
'ls',
186186
]),
187-
).rejects.toMatchObject({ details: { reason: 'managed-device-transport-mismatch' } });
187+
).rejects.toThrowError(/cannot select another server/);
188188
expect(providerCalls).toEqual([]);
189189

190+
// The server this lease holds is the one port the provider may be handed a request for, argv
191+
// included, and the request still travels as the caller wrote it.
192+
await capture({ serial: DEVICE.id, serverPort: 15_037 }, [
193+
'-P',
194+
'15037',
195+
'-s',
196+
DEVICE.id,
197+
'shell',
198+
'ls',
199+
]);
200+
expect(providerCalls).toEqual([['-P', '15037', 'shell', 'ls']]);
201+
190202
// Without a lease the caller's own adb invocation is what runs, globals and all: the provider
191-
// receives the request with only this scope's `-s` pair removed.
203+
// receives the request with only this scope's `-s` pair removed, and no server rule applies.
204+
providerCalls.length = 0;
192205
await capture({ serial: DEVICE.id }, ['-t', '42', '-s', DEVICE.id, 'shell', 'ls']);
193-
expect(providerCalls).toEqual([['-t', '42', 'shell', 'ls']]);
194206
await capture({ serial: DEVICE.id }, ['-P', '9999', '-s', DEVICE.id, 'shell', 'ls']);
195207
expect(providerCalls).toEqual([
196208
['-t', '42', 'shell', 'ls'],

0 commit comments

Comments
 (0)