Documentation ¶
Index ¶
- type MockChannel
- func (m *MockChannel) Close() error
- func (m *MockChannel) CloseWrite() error
- func (m *MockChannel) Read(data []byte) (int, error)
- func (m *MockChannel) SendRequest(name string, wantReply bool, payload []byte) (bool, error)
- func (m *MockChannel) Stderr() io.ReadWriter
- func (m *MockChannel) Write(data []byte) (int, error)
- type MockConn
- type MockConnMetadata
- type MockNewChannel
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 ¶
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.
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) OpenChannel ¶
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 ¶
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.
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 ¶
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.