Documentation ¶
Overview ¶
mockssh implements a basic ssh server for use in unit tests.
Command execution in the server is implemented by a user provided handler function rather than executing a real shell.
Some inspiration is taken from but not based on: https://godoc.org/github.com/gliderlabs/ssh
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMockClient ¶
func NewMockClient(handler SessionHandler) *ssh.Client
NewMockClient starts a ssh server backed by the given handler and returns a client that is connected to it.
Types ¶
type Session ¶
type Session struct { Exec string // Command to execute. Env []string // Environment values provided by the client. Stdin io.Reader Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
Session represents the server side execution of the client's ssh.Session.
type SessionHandler ¶
type SessionHandler func(session *Session)
SessionHandler is a user provided function that processes/executes the command given to it in the given Session. Before finishing the handler must call session.Close or session.Exit.
Click to show internal directories.
Click to hide internal directories.