sshtest

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrivateKey = `` /* 443-byte string literal not displayed */

notsecret

View Source
var PublicKey = `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJfBviRTuS3BVn5rde9xQFrmylsHb8cJdpjuJJNVzMIj user@example.com`

Functions

func NullHandler

func NullHandler(ch ssh.Channel, in <-chan *ssh.Request)

func RequestReplyHandler

func RequestReplyHandler(t TestLogger, replies []RequestReply) func(ssh.Channel, <-chan *ssh.Request)

RequestReplyHandler returns a handler that replies to requests. It fails if the request does not match the expected request.

func TestPrivateKeyAsSlice

func TestPrivateKeyAsSlice() []byte

func TestPublicKey

func TestPublicKey() ssh.PublicKey

func TestPublicKeyAsSlice

func TestPublicKeyAsSlice() []byte

func TestSigner

func TestSigner(t TestLogger) ssh.Signer

Types

type RequestReply

type RequestReply struct {
	// Request is a regular expression that matches the request.
	Request string `yaml:"request"`

	// Reply is a string that is sent back to the client.
	Reply string `yaml:"reply"`

	// Status is the ssh exit status code.
	Status uint32 `yaml:"status,omitempty"`
	// contains filtered or unexported fields
}

RequestReply is a single request-reply pair.

type Server

type Server struct {
	Endpoint string
	Listener net.Listener
	Config   *ssh.ServerConfig
	Handler  func(ssh.Channel, <-chan *ssh.Request)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(hostKey ssh.Signer) *Server

func NewServerT added in v0.0.3

func NewServerT(t TestLogger, hostKey ssh.Signer) *Server

func (*Server) Close

func (s *Server) Close()

type StdLogger added in v0.0.3

type StdLogger struct{}

func (StdLogger) Error added in v0.0.3

func (StdLogger) Error(args ...any)

func (StdLogger) Errorf added in v0.0.3

func (StdLogger) Errorf(format string, args ...any)

func (StdLogger) Fatal added in v0.0.3

func (StdLogger) Fatal(args ...any)

func (StdLogger) Fatalf added in v0.0.3

func (StdLogger) Fatalf(format string, args ...any)

func (StdLogger) Log added in v0.0.3

func (StdLogger) Log(args ...any)

func (StdLogger) Logf added in v0.0.3

func (StdLogger) Logf(format string, args ...any)

type TestLogger added in v0.0.3

type TestLogger interface {
	Log(args ...any)
	Logf(format string, args ...any)
	Error(args ...any)
	Errorf(format string, args ...any)
	Fatal(args ...any)
	Fatalf(format string, args ...any)
}
var TestLoggerStd TestLogger = StdLogger{}

TestLoggerStd is a standard logger that logs to the standard logger.

Jump to

Keyboard shortcuts

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