testssh

package
v1.2.1-0...-93d4433 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package testssh is a tiny in-process SSH server used by tests in other packages. It's regular (non-test) code so it can be imported; it takes a *testing.T so setup failures are reported at the call site. The server accepts password auth for a single user/pass pair and serves:

  • direct-tcpip channels (for tunnel forwarding tests)
  • session channels with exec requests (for command tests)
  • session channels with the "sftp" subsystem (for transfer tests)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a running SSH server bound to a local port.

func Start

func Start(t *testing.T, user, password string) *Server

Start starts an SSH server on an ephemeral port. The returned server is auto-closed when the test finishes via t.Cleanup.

func StartAt

func StartAt(t *testing.T, addr, user, password string) *Server

StartAt is Start with a caller-chosen bind address. Pass "127.0.0.1:<port>" to bind a specific port — useful for reconnect tests that need to bring the same endpoint back up after a shutdown.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the host:port the server is listening on.

func (*Server) Close

func (s *Server) Close()

Close stops accepting new connections and forcibly drops every in-flight connection. Useful for simulating a server outage in reconnect tests.

Jump to

Keyboard shortcuts

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