ssh

package
v0.0.0-...-cd438a9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockChannel

type MockChannel struct {
	mock.Mock
	ReadError        error
	WriteError       error
	CloseError       error
	SendSuccess      bool
	SendError        error
	StderrReadWriter io.ReadWriter
}

MockChannel mocks an ssh.Channel

func (*MockChannel) Close

func (m *MockChannel) Close() error

Close signals end of channel use. No data may be sent after this call.

func (*MockChannel) CloseWrite

func (m *MockChannel) CloseWrite() error

CloseWrite signals the end of sending in-band data. Requests may still be sent, and the other side may still send data

func (*MockChannel) Read

func (m *MockChannel) Read(data []byte) (int, error)

Read reads up to len(data) bytes from the channel.

func (*MockChannel) SendRequest

func (m *MockChannel) SendRequest(name string, wantReply bool, payload []byte) (bool, error)

SendRequest sends a channel request. If wantReply is true, it will wait for a reply and return the result as a boolean, otherwise the return value will be false. Channel requests are out-of-band messages so they may be sent even if the data stream is closed or blocked by flow control.

func (*MockChannel) Stderr

func (m *MockChannel) Stderr() io.ReadWriter

Stderr returns an io.ReadWriter that writes to this channel with the extended data type set to stderr. Stderr may safely be read and written from a different goroutine than Read and Write respectively.

func (*MockChannel) Write

func (m *MockChannel) Write(data []byte) (int, error)

Write writes len(data) bytes to the channel.

type MockConn

type MockConn struct {
	MockConnMetadata
	RequestSuccess bool
	RequestData    []byte
	RequestError   error
	Channel        ssh.Channel
	Requests       <-chan *ssh.Request
	OpenError      error
	CloseError     error
	WaitError      error
}

MockConn mocks ssh.Conn

func (*MockConn) Close

func (m *MockConn) Close() error

Close closes the underlying network connection

func (*MockConn) OpenChannel

func (m *MockConn) OpenChannel(name string, data []byte) (ssh.Channel, <-chan *ssh.Request, error)

OpenChannel tries to open an channel. If the request is rejected, it returns *OpenChannelError. On success it returns the SSH Channel and a Go channel for incoming, out-of-band requests. The Go channel must be serviced, or the connection will hang.

func (*MockConn) SendRequest

func (m *MockConn) SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)

SendRequest sends a global request, and returns the reply. If wantReply is true, it returns the response status and payload. See also RFC4254, section 4.

func (*MockConn) Wait

func (m *MockConn) Wait() error

Wait blocks until the connection has shut down, and returns the error causing the shutdown.

type MockConnMetadata

type MockConnMetadata struct {
	mock.Mock
	UserName    string
	SessionData []byte
	ClientVer   []byte
	ServerVer   []byte
	Remote      net.Addr
	Local       net.Addr
}

MockConnMetadata mocks ssh.ConnMetadata

func (*MockConnMetadata) ClientVersion

func (m *MockConnMetadata) ClientVersion() []byte

ClientVersion returns the client's version string as hashed into the session ID.

func (*MockConnMetadata) LocalAddr

func (m *MockConnMetadata) LocalAddr() net.Addr

LocalAddr returns the local address for this connection.

func (*MockConnMetadata) RemoteAddr

func (m *MockConnMetadata) RemoteAddr() net.Addr

RemoteAddr returns the remote address for this connection.

func (*MockConnMetadata) ServerVersion

func (m *MockConnMetadata) ServerVersion() []byte

ServerVersion returns the server's version string as hashed into the session ID.

func (*MockConnMetadata) SessionID

func (m *MockConnMetadata) SessionID() []byte

SessionID returns the sesson hash, also denoted by H.

func (*MockConnMetadata) User

func (m *MockConnMetadata) User() string

User returns the user ID for this connection. It is empty if no authentication is used.

type MockNewChannel

type MockNewChannel struct {
	mock.Mock
	TypeName       string
	Channel        ssh.Channel
	AcceptErr      error
	RejectErr      error
	RequestChannel <-chan *ssh.Request
	ExtData        []byte
}

MockNewChannel mocks an ssh.NewChannel.

func (*MockNewChannel) Accept

func (m *MockNewChannel) Accept() (ssh.Channel, <-chan *ssh.Request, error)

Accept accepts the channel creation request. It returns the Channel and a Go channel containing SSH requests. The Go channel must be serviced otherwise the Channel will hang.

func (*MockNewChannel) ChannelType

func (m *MockNewChannel) ChannelType() string

ChannelType returns the type of the channel, as supplied by the client.

func (*MockNewChannel) ExtraData

func (m *MockNewChannel) ExtraData() []byte

ExtraData returns the arbitrary payload for this channel, as supplied by the client. This data is specific to the channel type.

func (*MockNewChannel) Reject

func (m *MockNewChannel) Reject(reason ssh.RejectionReason, message string) error

Reject rejects the channel creation request. After calling this, no other methods on the Channel may be called.

Jump to

Keyboard shortcuts

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