Skip to content

Commit 8ee4364

Browse files
amankansal-ltclaude
andcommitted
test(provider-webdriver): cover a named pipe refused before any upload read
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 744a5ff commit 8ee4364

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎packages/provider-webdriver/src/webdriver-utils.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import assert from 'node:assert/strict';
2+
import { execFile } from 'node:child_process';
23
import { promises as fs } from 'node:fs';
34
import path from 'node:path';
5+
import { promisify } from 'node:util';
46
import { afterEach, test, vi } from 'vitest';
57
import { AppError } from '@agent-device/kernel/errors';
68
import { asOptionalRecord } from '@agent-device/kernel/record';
@@ -15,6 +17,7 @@ import {
1517
import { mkdtempForTest } from './tmp-dir.fixtures.ts';
1618

1719
const realFetch = globalThis.fetch;
20+
const execFileAsync = promisify(execFile);
1821

1922
afterEach(() => {
2023
globalThis.fetch = realFetch;
@@ -150,3 +153,27 @@ test('appFileUploadForm carries a regular app file and refuses anything else typ
150153
await fs.rm(tempDir, { recursive: true, force: true });
151154
}
152155
});
156+
157+
test.skipIf(process.platform === 'win32')(
158+
'appFileUploadForm refuses a named pipe without reading it',
159+
async () => {
160+
const tempDir = await mkdtempForTest('agent-device-upload-form-fifo-');
161+
try {
162+
const fifoPath = path.join(tempDir, 'App.ipa');
163+
await execFileAsync('mkfifo', [fifoPath]);
164+
165+
await assert.rejects(
166+
appFileUploadForm(fifoPath, 'file', { provider: 'hub', service: 'Hub' }),
167+
(error: unknown) => {
168+
assert.ok(error instanceof AppError);
169+
assert.equal(error.code, 'INVALID_ARGS');
170+
assert.equal(error.message, `Hub can only upload a regular app file: ${fifoPath}`);
171+
assert.equal(error.details?.appPath, fifoPath);
172+
return true;
173+
},
174+
);
175+
} finally {
176+
await fs.rm(tempDir, { recursive: true, force: true });
177+
}
178+
},
179+
);

0 commit comments

Comments
 (0)