Documentation
¶
Index ¶
- func GenerateSSHKeypair(t *testing.T) (keyFile string, pubKey ssh.PublicKey)
- func GenerateSSHKeypairAt(t *testing.T, path string) ssh.PublicKey
- type Collaboration
- type CommandResponse
- type ExecResponse
- type FakeAnthropic
- type FakeCircleCI
- type FakeGitHub
- type Project
- type RunResponse
- type SSHServer
- func (s *SSHServer) Addr() string
- func (s *SSHServer) Commands() []string
- func (s *SSHServer) EnvVars() map[string]string
- func (s *SSHServer) Reset()
- func (s *SSHServer) RestrictToKey(authorizedKey ssh.PublicKey)
- func (s *SSHServer) SetResult(stdout string, exitCode int)
- func (s *SSHServer) SetResultFn(fn func(command string) (stdout string, exitCode int))
- type Sidecar
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSSHKeypair ¶ added in v0.7.9
GenerateSSHKeypair generates an ed25519 keypair, writes the private and public key files to a temp directory, and returns the private key file path and the corresponding ssh.PublicKey.
func GenerateSSHKeypairAt ¶ added in v0.7.186
GenerateSSHKeypairAt generates an ed25519 keypair at the given path (private key at path, public key at path+".pub") and returns the parsed public key. The destination directory is created if it does not exist.
Types ¶
type Collaboration ¶
type CommandResponse ¶ added in v0.7.97
type ExecResponse ¶
type FakeAnthropic ¶
type FakeAnthropic struct {
http.Handler
Recorder *recorder.RequestRecorder
// contains filtered or unexported fields
}
FakeAnthropic serves canned responses for the Anthropic Messages API.
func NewFakeAnthropic ¶
func NewFakeAnthropic(responses ...string) *FakeAnthropic
func (*FakeAnthropic) SetTokenLimitErrors ¶
func (f *FakeAnthropic) SetTokenLimitErrors(n int)
SetTokenLimitErrors configures the fake to return n consecutive "prompt is too long" errors before returning normal responses.
type FakeCircleCI ¶
type FakeCircleCI struct {
http.Handler
Recorder *recorder.RequestRecorder
Collaborations []Collaboration
Projects []Project
Sidecars []Sidecar
Snapshots []Snapshot
RunResponse *RunResponse
AddKeyURL string
ExecResponse *ExecResponse
CommandResponse *CommandResponse
RunStatusCode int // override status code for trigger run endpoint
// Per-endpoint status code overrides for testing error responses.
CollaborationsStatusCode int // override for GET /me/collaborations
ListStatusCode int // override for GET /sidecar/instances
CreateStatusCode int // override for POST /sidecar/instances
CreateErrorAfter int // if > 0, fail creates after this many successes
DeleteStatusCode int // override for DELETE /sidecar/instances/:id
PruneStatusCode int // override for POST /sidecar/instances/prune
ExecStatusCode int // override for POST /sidecar/instances/:id/exec
ExecMessage string // V3 error title when ExecStatusCode is set
CommandOutputStatusCode int // override for GET /sidecar/commands/:id/output
CommandOutputMessage string // error message body when CommandOutputStatusCode is set
// DropStreamsBeforeExit ends this many output streams after delivering their
// output but before the terminal event, so client resume can be exercised.
DropStreamsBeforeExit int
// EmptyStreamsBeforeExit returns this many completely empty output responses
// (status 200, no body) before serving the real stream. This simulates an
// interrupted connection where no SSE frames arrive at all, which the client
// must treat as a resume trigger rather than a failure.
EmptyStreamsBeforeExit int
AddKeyStatusCode int // override for POST /sidecar/instances/:id/ssh/add-key
StaleIDs map[string]bool // IDs that return 404 from the add-key endpoint
NotFoundBeforeAddKey map[string]int // initial add-key calls that return 404 before succeeding
OutdatedIDs map[string]bool // IDs that return an out-of-date 410 from the add-key endpoint
StaleAfterAddKey map[string]int // successful add-key calls allowed before an ID returns 404
CreateSnapshotStatusCode int // override for POST /sidecar/snapshots
GetSnapshotStatusCode int // override for GET /sidecar/snapshots/:id
ListSnapshotsStatusCode int // override for GET /sidecar/snapshots
GetCommandStatusCode int // override for GET /sidecar/commands/:id
CreateOrgStatusCode int // override for POST /api/v2/organization
// ExtraHeaders are added to every response. Use to inject Deprecation/Sunset
// headers without changing individual handler logic.
ExtraHeaders http.Header
// contains filtered or unexported fields
}
FakeCircleCI serves canned responses for the CircleCI API.
func NewFakeCircleCI ¶
func NewFakeCircleCI() *FakeCircleCI
func (*FakeCircleCI) ServeHTTP ¶ added in v0.7.124
func (f *FakeCircleCI) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP injects ExtraHeaders into every response before delegating to the embedded gin handler. Headers must be set before the first Write or WriteHeader call, which gin does internally — setting them here satisfies that ordering.
type FakeGitHub ¶
type FakeGitHub struct {
http.Handler
Recorder *recorder.RequestRecorder
// contains filtered or unexported fields
}
FakeGitHub serves canned responses for GitHub's GraphQL API.
func NewFakeGitHub ¶
func NewFakeGitHub() *FakeGitHub
func (*FakeGitHub) SetOrgRepos ¶
func (f *FakeGitHub) SetOrgRepos(resp string)
func (*FakeGitHub) SetOrgValidation ¶
func (f *FakeGitHub) SetOrgValidation(resp string)
func (*FakeGitHub) SetRateLimit ¶
func (f *FakeGitHub) SetRateLimit(resp string)
func (*FakeGitHub) SetRepoError ¶
func (f *FakeGitHub) SetRepoError(repo string, resp string)
func (*FakeGitHub) SetReviewActivity ¶
func (f *FakeGitHub) SetReviewActivity(repo string, resp string)
type RunResponse ¶
type SSHServer ¶ added in v0.7.9
type SSHServer struct {
// contains filtered or unexported fields
}
SSHServer is a WebSocket+SSH server for testing SSH-based sidecar interactions. It accepts a single authorized public key and records exec requests.
func NewSSHServer ¶ added in v0.7.9
NewSSHServer starts a WebSocket+SSH server that accepts connections authenticated with authorizedKey. The server is shut down automatically when the test ends.
func NewSSHServerAcceptingAnyKey ¶ added in v0.7.186
NewSSHServerAcceptingAnyKey starts a server like NewSSHServer but authorises whichever key the client presents. Use it when chunk generates the keypair itself, so the test cannot know the public key in advance. Pair it with RestrictToKey once the generated key is known.
func (*SSHServer) Addr ¶ added in v0.7.9
Addr returns the "host:port" address the server is listening on. sidecar.OpenSession stores this as Session.URL; toWebSocketURL converts it to ws://host:port/ssh/tunnel before dialling.
func (*SSHServer) Commands ¶ added in v0.7.9
Commands returns a copy of all exec command strings received so far.
func (*SSHServer) EnvVars ¶ added in v0.7.57
EnvVars returns a copy of all environment variables received via "env" requests.
func (*SSHServer) Reset ¶ added in v0.7.122
func (s *SSHServer) Reset()
Reset clears the recorded commands so a test can assert on a fresh sync.
func (*SSHServer) RestrictToKey ¶ added in v0.7.186
RestrictToKey narrows the server to accept only authorizedKey from now on. Keeping the same server (and so the same host key and address) lets a test first let chunk generate a keypair, then prove the private key chunk kept is the pair of the public key it registered.
func (*SSHServer) SetResult ¶ added in v0.7.9
SetResult configures the stdout output and exit code returned for exec requests.
func (*SSHServer) SetResultFn ¶ added in v0.7.147
SetResultFn configures a per-command result and takes precedence over SetResult. Use it when a test needs one command in a sequence to behave differently from the rest — a validate command exiting 127 while the sync commands before it succeed, say. The function is called outside the server's lock, so it may block to simulate a command that never returns.