Method: Net::SSH::Test::Packet#types

Defined in:
lib/net/ssh/test/packet.rb

#typesObject

Returns an array of symbols describing the data elements for packets of the same type as this packet. These types are used to either validate sent packets (Net::SSH::Test::LocalPacket) or build received packets (Net::SSH::Test::RemotePacket).

Not all packet types are defined here. As new packet types are required (e.g., a unit test needs to test that the remote host sent a packet that is not implemented here), the description of that packet should be added. Unsupported packet types will otherwise raise an exception.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/net/ssh/test/packet.rb', line 70

def types
  @types ||= case @type
             when KEXINIT
               i[long long long long
                  string string string string string string string string string string
                  bool]
             when NEWKEYS then []
             when CHANNEL_OPEN then i[string long long long]
             when CHANNEL_OPEN_CONFIRMATION then i[long long long long]
             when CHANNEL_DATA then i[long string]
             when CHANNEL_EXTENDED_DATA then i[long long string]
             when CHANNEL_EOF, CHANNEL_CLOSE, CHANNEL_SUCCESS, CHANNEL_FAILURE then [:long]
             when CHANNEL_REQUEST
               parts = i[long string bool]
               case @data[1]
               when "exec", "subsystem", "shell" then parts << :string
               when "exit-status" then parts << :long
               when "pty-req" then parts.concat(i[string long long long long string])
               when "env" then parts.contact(i[string string])
               else
                 request = Packet.registered_channel_requests(@data[1])
                 raise "don't know what to do about #{@data[1]} channel request" unless request

                 parts.concat(request[:extra_parts])
               end
             else raise "don't know how to parse packet type #{@type}"
             end
end