/** * E2E Test Runner - Shell/CLI Adapter * * Executes shell commands as test steps. Supports command execution with * stdout/stderr capture, exit code checking, timeout, cwd, and env overrides. * * SECURITY NOTE: This adapter intentionally uses child_process.exec() (not execFile) * because users need full shell features (pipes, redirects, globbing, subshells). * This is safe because: * - The `command` field comes from YAML test files written by the test author * - This is the same trust model as any CI/CD system or test runner * - The adapter runs in a testing context, not a production web server * - No untrusted user input reaches exec() -- commands are static YAML values */ import type { AdapterConfig, AdapterContext, AdapterStepResult, Logger } from '../types'; import { BaseAdapter } from './base.adapter'; /** * Parameters for the shell exec action. */ export interface ShellRequestParams { /** Shell command to execute. */ command: string; /** Working directory override. */ cwd?: string; /** Command timeout in milliseconds. */ timeout?: number; /** Environment variables merged with process.env. */ env?: Record; /** Capture map: variable name to source (stdout, stderr, exitCode). */ capture?: Record; /** Inline assertions on the command result. */ assert?: ShellAssertion; } /** * Shell command execution response data. */ export interface ShellResponse { /** Process exit code (0 = success). */ exitCode: number; /** Standard output content. */ stdout: string; /** Standard error content. */ stderr: string; /** Execution duration in milliseconds. */ duration: number; } /** * Assertion schema for shell command results. * * Note: `equals` on stdout/stderr trims surrounding whitespace to handle * the trailing newline that shell commands (e.g. echo) add by default. */ export interface ShellAssertion { /** Expected exit code (exact match). */ exitCode?: number; /** Assertions on stdout content. */ stdout?: { contains?: string; matches?: string; equals?: string; }; /** Assertions on stderr content. */ stderr?: { contains?: string; matches?: string; equals?: string; }; } /** * Shell/CLI adapter for executing shell commands as test steps. * * Uses Node.js child_process.exec() for full shell feature support * (pipes, redirects, globbing). Commands come from YAML test files * authored by the test writer, following the same trust model as CI/CD. */ export declare class ShellAdapter extends BaseAdapter { private defaultTimeout; private defaultCwd?; private defaultEnv?; constructor(config: AdapterConfig, logger: Logger); /** * Get the adapter name for logging. */ get name(): string; /** * Connect - no persistent connection needed for shell execution. */ connect(): Promise; /** * Disconnect - release connected state. */ disconnect(): Promise; /** * Health check by running a simple echo command. */ healthCheck(): Promise; /** * Execute a shell action. * * Only the 'exec' action is supported. Runs the specified command, * captures stdout/stderr/exitCode, runs assertions, and captures values. */ execute(action: string, params: Record, ctx: AdapterContext): Promise; /** * Execute a shell command and return its output. * * Handles non-zero exit codes as data (not errors), timeouts as * AdapterError, and system-level failures (ENOENT) as AdapterError. * * Uses exec() intentionally for full shell feature support -- commands * originate from static YAML test files, not untrusted user input. */ private runCommand; /** * Run inline assertions on shell command output. * * Throws AssertionError if any assertion fails. */ private runAssertions; } //# sourceMappingURL=shell.adapter.d.ts.map