Class: Net::SSH::Test::RemotePacket
- 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_INIT, Net::SSH::Transport::Constants::KEXDH_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
-
#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).
-
#remote? ⇒ Boolean
Returns
true
; this is a remote packet. -
#to_s ⇒ Object
Returns this remote packet as a string, suitable for parsing by Net::SSH::Transport::PacketStream and friends.
Methods inherited from Packet
#initialize, #instantiate!, #local?, #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.
21 22 23 |
# File 'lib/net/ssh/test/remote_packet.rb', line 21 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.
12 13 14 |
# File 'lib/net/ssh/test/remote_packet.rb', line 12 def remote? true end |
#to_s ⇒ Object
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.
29 30 31 32 33 34 35 |
# File 'lib/net/ssh/test/remote_packet.rb', line 29 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 |