mirror of
https://github.com/stablyai/orca.git
synced 2026-10-26 00:03:55 +00:00
* refactor oversized Electron facilities * fix interactive process timeout and shortcut repeat guard * chore(child-process): drop stale cli-installer allowlist entry cli-installer.ts now routes privileged spawns through runProcess via cli-privileged-processes.ts, so the shrink-only ratchet flags it as stale. * refactor(child-process): extract the bounded output sink runProcess's timeoutMs opt-out (required to preserve the unbounded osascript admin prompt) pushed run-process.ts past the 300-line cap. Move createOutputSink to its own module rather than add a max-lines bypass, which AGENTS.md forbids. Moved verbatim; no behavior change.
81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const runProcessMock = vi.hoisted(() => vi.fn())
|
|
|
|
vi.mock('../../shared/child-process/run-process', () => ({ runProcess: runProcessMock }))
|
|
|
|
import { runMacPrivilegedCommand, runWindowsPathCommand } from './cli-privileged-processes'
|
|
|
|
describe('Windows CLI PATH process boundary', () => {
|
|
beforeEach(() => runProcessMock.mockReset())
|
|
|
|
it('uses the canonical process wrapper with the bounded timeout', async () => {
|
|
runProcessMock.mockResolvedValue({
|
|
code: 0,
|
|
signal: null,
|
|
stdout: 'ok',
|
|
stderr: '',
|
|
timedOut: false
|
|
})
|
|
|
|
await expect(runWindowsPathCommand(['-NoProfile'])).resolves.toBe('ok')
|
|
expect(runProcessMock).toHaveBeenCalledWith({
|
|
program: 'powershell',
|
|
args: ['-NoProfile'],
|
|
timeoutMs: 5_000
|
|
})
|
|
})
|
|
|
|
it('preserves the timeout error presented by CLI registration', async () => {
|
|
runProcessMock.mockResolvedValue({
|
|
code: null,
|
|
signal: null,
|
|
stdout: '',
|
|
stderr: '',
|
|
timedOut: true
|
|
})
|
|
|
|
await expect(runWindowsPathCommand([])).rejects.toThrow(
|
|
'Windows PATH command timed out after 5000ms.'
|
|
)
|
|
})
|
|
|
|
it('retains stderr for permission classification', async () => {
|
|
runProcessMock.mockResolvedValue({
|
|
code: 1,
|
|
signal: null,
|
|
stdout: '',
|
|
stderr: 'UnauthorizedAccessException',
|
|
timedOut: false
|
|
})
|
|
|
|
await expect(runWindowsPathCommand([])).rejects.toMatchObject({
|
|
code: 1,
|
|
message: 'UnauthorizedAccessException',
|
|
stderr: 'UnauthorizedAccessException'
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('macOS CLI privileged process boundary', () => {
|
|
beforeEach(() => runProcessMock.mockReset())
|
|
|
|
it('uses the canonical process wrapper without a shell', async () => {
|
|
runProcessMock.mockResolvedValue({
|
|
code: 0,
|
|
signal: null,
|
|
stdout: '',
|
|
stderr: '',
|
|
timedOut: false
|
|
})
|
|
|
|
await runMacPrivilegedCommand("ln -s 'source' 'target'")
|
|
|
|
expect(runProcessMock).toHaveBeenCalledWith({
|
|
program: 'osascript',
|
|
args: ['-e', "do shell script \"ln -s 'source' 'target'\" with administrator privileges"],
|
|
timeoutMs: null
|
|
})
|
|
})
|
|
})
|