Documentation
¶
Overview ¶
Package testenv provides reusable SSH servers and fault injectors for tests.
Index ¶
- Variables
- type Auth
- type ContainerSSHD
- func (c *ContainerSSHD) Addr() string
- func (c *ContainerSSHD) Auth() *Auth
- func (c *ContainerSSHD) ClientConfig() *ssh.ClientConfig
- func (c *ContainerSSHD) Close(ctx context.Context) error
- func (c *ContainerSSHD) Drop(ctx context.Context) error
- func (c *ContainerSSHD) Freeze(ctx context.Context) error
- func (c *ContainerSSHD) Resume(ctx context.Context) error
- type Server
Constants ¶
This section is empty.
Variables ¶
ErrContainerRuntimeUnavailable means neither Docker nor Podman is usable.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
Auth contains a generated client identity and matching SSH configurations.
func (*Auth) ClientConfig ¶
func (a *Auth) ClientConfig() *ssh.ClientConfig
ClientConfig returns a client configuration that trusts the ephemeral host.
func (*Auth) ServerConfig ¶
func (a *Auth) ServerConfig(hostKey ssh.Signer) *ssh.ServerConfig
ServerConfig returns a server configuration accepting only this identity.
type ContainerSSHD ¶
type ContainerSSHD struct {
// contains filtered or unexported fields
}
ContainerSSHD is an isolated OpenSSH fixture managed by Docker or Podman.
func StartContainerSSHD ¶
func StartContainerSSHD(ctx context.Context) (*ContainerSSHD, error)
StartContainerSSHD launches a containerized sshd and waits until it accepts the generated public key. SSH_E2E_IMAGE overrides the fixture image.
func (*ContainerSSHD) Addr ¶
func (c *ContainerSSHD) Addr() string
Addr returns the host-mapped SSH address.
func (*ContainerSSHD) Auth ¶
func (c *ContainerSSHD) Auth() *Auth
Auth returns the generated identity used by the fixture.
func (*ContainerSSHD) ClientConfig ¶
func (c *ContainerSSHD) ClientConfig() *ssh.ClientConfig
ClientConfig returns the matching generated client configuration.
func (*ContainerSSHD) Close ¶
func (c *ContainerSSHD) Close(ctx context.Context) error
Close removes the fixture if it is still present.
func (*ContainerSSHD) Drop ¶
func (c *ContainerSSHD) Drop(ctx context.Context) error
Drop kills the sshd container, deterministically dropping its connections.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an in-process SSH server listening on a real loopback socket.
func Start ¶
Start starts an SSH server authenticated by auth. Session exec requests are run with the host's /bin/sh, which makes the fixture useful for integration tests without requiring an external sshd.
func (*Server) Drop ¶
func (s *Server) Drop()
Drop closes every currently established TCP connection without stopping the listener. New connections can be established immediately afterward.