mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
test: remove 54 low-value agent-hook, SSH and PTY tests
This commit is contained in:
@@ -5,32 +5,19 @@ import { runProcess } from '@orca/process-host'
|
||||
import { wrapRemoteCommandForPosixShell } from './ssh-posix-command-wrapper'
|
||||
import type { SshExecOptions } from '../connection/ssh-exec-options'
|
||||
import { execCommand } from './remote-exec-command'
|
||||
import {
|
||||
captureOrcadStateSnapshotCommand,
|
||||
parseOrcadSnapshotCapture
|
||||
} from '../../managed-server/host-state/orcad-state-snapshot'
|
||||
import { getRemoteHostPlatform } from '../remote-host/ssh-remote-platform'
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync, existsSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
type HostOptions = {
|
||||
/** PATH on the host; '' leaves only shell builtins, so no base64 or gzip. */
|
||||
path?: string
|
||||
/** An SSH gateway that cuts the exec request at this many bytes and merges stderr into stdout. */
|
||||
gatewayLimitBytes?: number
|
||||
}
|
||||
|
||||
/** Exercise the actual transport wrapper through real /bin/sh. */
|
||||
function host(options: HostOptions = {}) {
|
||||
const exec = vi.fn()
|
||||
exec.mockImplementation(async (command: string, execOptions?: SshExecOptions) => {
|
||||
let remote = wrapRemoteCommandForPosixShell(command, {
|
||||
const remote = wrapRemoteCommandForPosixShell(command, {
|
||||
compress: execOptions?.compressCommand === true
|
||||
})
|
||||
if (options.gatewayLimitBytes !== undefined) {
|
||||
remote = `${Buffer.from(remote).subarray(0, options.gatewayLimitBytes).toString()} 2>&1`
|
||||
}
|
||||
const result = await runProcess({
|
||||
program: '/bin/sh',
|
||||
args: ['-c', remote],
|
||||
@@ -68,32 +55,5 @@ describe.skipIf(process.platform === 'win32')(
|
||||
false
|
||||
])
|
||||
})
|
||||
|
||||
it('captures a snapshot whole through a gateway that cuts exec requests at 6 KiB and merges stderr', async () => {
|
||||
const base = mkdtempSync(join(tmpdir(), 'orcad-gateway-capture-'))
|
||||
try {
|
||||
const root = join(base, '.orca')
|
||||
mkdirSync(join(root, 'profiles'), { recursive: true })
|
||||
writeFileSync(join(root, 'profiles', 'p.json'), 'state')
|
||||
const snapshot = join(base, '.orca-remote', 'orcad-state-snapshots', 'pre-1')
|
||||
const command = captureOrcadStateSnapshotCommand(
|
||||
getRemoteHostPlatform('linux-x64'),
|
||||
root,
|
||||
snapshot,
|
||||
join(base, '.orca-remote')
|
||||
)
|
||||
const gatewayLimitBytes = 6 * 1024
|
||||
expect(
|
||||
Buffer.byteLength(wrapRemoteCommandForPosixShell(command, { compress: false }))
|
||||
).toBeLessThan(gatewayLimitBytes)
|
||||
|
||||
const output = await execCommand(host({ gatewayLimitBytes }), command)
|
||||
|
||||
expect(parseOrcadSnapshotCapture(output)).toBe('captured')
|
||||
expect(existsSync(join(snapshot, 'state.tar'))).toBe(true)
|
||||
} finally {
|
||||
rmSync(base, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user