Documentation
¶
Overview ¶
Package sshtest runs an SSH server inside the test process, on 127.0.0.1, for SSHManager tests. It logs users in with a password, a public key or keyboard-interactive questions, answers "exec" with a tiny built-in command set, echoes a PTY shell's input and serves SFTP from memory. It never runs a real command and never touches the real filesystem, so the tests behave the same on every OS.
Index ¶
- func NewHostKey(t testing.TB) ssh.Signer
- type Config
- type Question
- type Server
- func (s *Server) Address() string
- func (s *Server) AuthTries() []string
- func (s *Server) BlockReads() (blocked <-chan struct{}, release func())
- func (s *Server) Close()
- func (s *Server) Connections() int
- func (s *Server) DropConnections()
- func (s *Server) EncryptedClientKey(t testing.TB, passphrase string) []byte
- func (s *Server) Execs() []string
- func (s *Server) HostKey() ssh.PublicKey
- func (s *Server) Logins() int
- func (s *Server) PTYs() [][2]int
- func (s *Server) Resizes() [][2]int
- func (s *Server) SetHostKey(key ssh.Signer)
- func (s *Server) Signals() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
User string
// Password, when set, is accepted by password logins.
Password string
// Questions, when set, are asked in one keyboard-interactive round.
Questions []Question
// PublicKey accepts logins with ClientKey.
PublicKey bool
}
Config sets how the server logs users in.
type Server ¶
type Server struct {
Host string
Port int
User string
// ClientKey is the key PublicKey logins accept; ClientKeyPEM is its
// unencrypted OpenSSH private key.
ClientKey ed25519.PrivateKey
ClientKeyPEM []byte
// contains filtered or unexported fields
}
Server is a running test server.
func (*Server) BlockReads ¶
func (s *Server) BlockReads() (blocked <-chan struct{}, release func())
BlockReads makes SFTP file reads wait until release is called; blocked is closed once a read is waiting.
func (*Server) Connections ¶
Connections counts open connections.
func (*Server) DropConnections ¶
func (s *Server) DropConnections()
DropConnections closes every open connection, as a server restart would.
func (*Server) EncryptedClientKey ¶
EncryptedClientKey returns ClientKey as an OpenSSH private key encrypted with passphrase.
func (*Server) SetHostKey ¶
SetHostKey makes later connections present key.