Class: Net::SSH::Test::RemotePacket

Inherits:
Packet
  • Object
show all
Defined in:
lib/net/ssh/test/remote_packet.rb

Overview

This is a specialization of Net::SSH::Test::Packet for representing mock packets that are received by the local (client) host. These are created automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any of the gets_* methods.

Constant Summary

Constants included from Connection::Constants

Connection::Constants::CHANNEL_CLOSE, Connection::Constants::CHANNEL_DATA, Connection::Constants::CHANNEL_EOF, Connection::Constants::CHANNEL_EXTENDED_DATA, Connection::Constants::CHANNEL_FAILURE, Connection::Constants::CHANNEL_OPEN, Connection::Constants::CHANNEL_OPEN_CONFIRMATION, Connection::Constants::CHANNEL_OPEN_FAILURE, Connection::Constants::CHANNEL_REQUEST, Connection::Constants::CHANNEL_SUCCESS, Connection::Constants::CHANNEL_WINDOW_ADJUST, Connection::Constants::GLOBAL_REQUEST, Connection::Constants::REQUEST_FAILURE, Connection::Constants::REQUEST_SUCCESS

Constants included from Net::SSH::Transport::Constants

Net::SSH::Transport::Constants::DEBUG, Net::SSH::Transport::Constants::DISCONNECT, Net::SSH::Transport::Constants::IGNORE, Net::SSH::Transport::Constants::KEXDH_GEX_GROUP, Net::SSH::Transport::Constants::KEXDH_GEX_INIT, Net::SSH::Transport::Constants::KEXDH_GEX_REPLY, Net::SSH::Transport::Constants::KEXDH_GEX_REQUEST, Net::SSH::Transport::Constants::KEXDH_INIT, Net::SSH::Transport::Constants::KEXDH_REPLY, Net::SSH::Transport::Constants::KEXECDH_INIT, Net::SSH::Transport::Constants::KEXECDH_REPLY, Net::SSH::Transport::Constants::KEXINIT, Net::SSH::Transport::Constants::NEWKEYS, Net::SSH::Transport::Constants::SERVICE_ACCEPT, Net::SSH::Transport::Constants::SERVICE_REQUEST, Net::SSH::Transport::Constants::UNIMPLEMENTED

Instance Method Summary collapse

Methods inherited from Packet

#initialize, #instantiate!, #local?, register_channel_request, registered_channel_requests, #types

Constructor Details

This class inherits a constructor from Net::SSH::Test::Packet

Instance Method Details

#process(packet) ⇒ Object

The #process method should only be called on Net::SSH::Test::LocalPacket packets; if it is attempted on a remote packet, then it is an expectation mismatch (a remote packet was received when a local packet was expected to be sent). This will happen when either your test script (Net::SSH::Test::Script) or your program are wrong.


23
24
25
# File 'lib/net/ssh/test/remote_packet.rb', line 23

def process(packet)
  raise "received packet type #{packet.read_byte} and was not expecting any packet"
end

#remote?Boolean

Returns true; this is a remote packet.

Returns:

  • (Boolean)

14
15
16
# File 'lib/net/ssh/test/remote_packet.rb', line 14

def remote?
  true
end

#to_sObject

Returns this remote packet as a string, suitable for parsing by Net::SSH::Transport::PacketStream and friends. When a remote packet is received, this method is called and the result concatenated onto the input buffer for the packet stream.


31
32
33
34
35
36
37
# File 'lib/net/ssh/test/remote_packet.rb', line 31

def to_s
  @to_s ||= begin
    instantiate!
    string = Net::SSH::Buffer.from(:byte, @type, *types.zip(@data).flatten).to_s
    [string.length, string].pack("NA*")
  end
end