gatewaytest

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gatewaytest starts a real sailwright-gateway against a fake sailwright CLI. It is shared by the gateway integration tests and the E2E module's self-test.

Index

Constants

View Source
const AgentWorkspace = "/workspaces/test"

AgentWorkspace is the agent-side path mapped to Harness.WorkspaceHost.

Variables

This section is empty.

Functions

func BuildFakeCLI

func BuildFakeCLI(t testing.TB) string

BuildFakeCLI compiles the fake sailwright CLI once per test process.

Types

type Harness

type Harness struct {
	URL           string
	SocketPath    string
	ViewURL       string
	AgentDir      string
	Token         string
	StateDir      string
	RecordFile    string
	FakeStateDir  string
	WorkspaceHost string
	Gateway       *gateway.Gateway
	Console       *SyncBuffer
	// contains filtered or unexported fields
}

Harness is a running gateway with a fake CLI behind it.

func Start

func Start(t testing.TB, opts Options) *Harness

Start launches a gateway on a random loopback port.

func (*Harness) Approve

func (h *Harness) Approve(t testing.TB, jobID string)

Approve answers the pending approval for jobID on the gateway console.

func (*Harness) ApproveSudo

func (h *Harness) ApproveSudo(t testing.TB, jobID string, password string)

ApproveSudo approves jobID with a sudo password, as the operator would type it.

func (*Harness) Connect

func (h *Harness) Connect(t testing.TB) *mcp.ClientSession

Connect opens an MCP client session over TCP with the harness token.

func (*Harness) ConnectTo

func (h *Harness) ConnectTo(t testing.TB, endpoint client.Endpoint) *mcp.ClientSession

ConnectTo opens an MCP client session to the given endpoint.

func (*Harness) Deny

func (h *Harness) Deny(t testing.TB, jobID string)

Deny rejects the pending approval for jobID on the gateway console.

func (*Harness) Invocations

func (h *Harness) Invocations(t testing.TB) []Invocation

Invocations returns every recorded fake CLI call.

func (*Harness) SocketEndpoint

func (h *Harness) SocketEndpoint() client.Endpoint

SocketEndpoint returns the Unix socket endpoint (empty Socket on Windows).

func (*Harness) TCPEndpoint

func (h *Harness) TCPEndpoint() client.Endpoint

TCPEndpoint returns the TCP endpoint with the harness token.

func (*Harness) WaitForPrompt

func (h *Harness) WaitForPrompt(t testing.TB, jobID string)

WaitForPrompt blocks until the console shows the approval prompt for jobID.

type Invocation

type Invocation struct {
	Argv []string `json:"argv"`
	Cwd  string   `json:"cwd"`
	Env  []string `json:"env"`
}

Invocation is one recorded fake CLI call.

type Options

type Options struct {
	Approvals     bool
	ApprovalTTL   time.Duration
	PullAllowlist []string
	JobTimeout    string
	FollowOutput  bool
	// LiveTail receives the running job's output for the terminal tail.
	LiveTail gateway.LiveTail
	// GateForeignVMs enables the rule that VMs the gateway did not create need
	// operator approval (on in real gateways; off by default in tests).
	GateForeignVMs bool
	// AutoApprovals uses the --bypass-approvals approver instead of the console.
	AutoApprovals bool
	// NoWorkspace leaves agent_workspaces in gateway.yaml empty, as on a fresh host.
	NoWorkspace bool
}

Options configure a test gateway.

type SyncBuffer

type SyncBuffer struct {
	// contains filtered or unexported fields
}

SyncBuffer is a goroutine-safe text buffer.

func (*SyncBuffer) String

func (b *SyncBuffer) String() string

String returns the buffered text.

func (*SyncBuffer) Write

func (b *SyncBuffer) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL