diff options
author | Miklós Fazekas <mfazekas@szemafor.com> | 2016-04-08 21:13:54 +0200 |
---|---|---|
committer | Miklós Fazekas <mfazekas@szemafor.com> | 2016-04-08 21:13:54 +0200 |
commit | 035f27c705aed4fbfd9bc66b3f8e99bbc4141cb3 (patch) | |
tree | 351892fedcfb07987e9262f3f2f18cb7976835be | |
parent | 093bca8df4b0299bd991f881168ddd07e1ca1a23 (diff) | |
parent | 40a07fd57b882073298440ec617b2c508fdad40b (diff) | |
download | net-ssh-035f27c705aed4fbfd9bc66b3f8e99bbc4141cb3.tar.gz |
Merge pull request #283 from p0deje/test_channel_requests_pty
Add Net::SSH::Test::Channel#sends_request_pty for scripting PTY requests
-rw-r--r-- | lib/net/ssh/test/channel.rb | 7 | ||||
-rw-r--r-- | lib/net/ssh/test/packet.rb | 1 | ||||
-rw-r--r-- | lib/net/ssh/test/script.rb | 9 |
3 files changed, 17 insertions, 0 deletions
diff --git a/lib/net/ssh/test/channel.rb b/lib/net/ssh/test/channel.rb index 1b58671..2eb7a12 100644 --- a/lib/net/ssh/test/channel.rb +++ b/lib/net/ssh/test/channel.rb @@ -98,6 +98,13 @@ module Net; module SSH; module Test script.sends_channel_close(self) end + # Scripts the sending of a "request pty" request packet across the channel. + # + # channel.sends_request_pty + def sends_request_pty + script.sends_channel_request_pty(self) + end + # Scripts the reception of a channel data packet from the remote end. # # channel.gets_data "bar" diff --git a/lib/net/ssh/test/packet.rb b/lib/net/ssh/test/packet.rb index 60cf4e6..8767253 100644 --- a/lib/net/ssh/test/packet.rb +++ b/lib/net/ssh/test/packet.rb @@ -72,6 +72,7 @@ module Net; module SSH; module Test case @data[1] when "exec", "subsystem" then parts << :string when "exit-status" then parts << :long + when "pty-req" then parts += [:string, :long, :long, :long, :long, :string] else raise "don't know what to do about #{@data[1]} channel request" end else raise "don't know how to parse packet type #{@type}" diff --git a/lib/net/ssh/test/script.rb b/lib/net/ssh/test/script.rb index 701defc..d3813c3 100644 --- a/lib/net/ssh/test/script.rb +++ b/lib/net/ssh/test/script.rb @@ -104,6 +104,15 @@ module Net; module SSH; module Test events << LocalPacket.new(:channel_close, channel.remote_id) end + # Scripts the sending of a channel request pty packets from the given + # Net::SSH::Test::Channel +channel+. This will typically be called via + # Net::SSH::Test::Channel#sends_request_pty. + def sends_channel_request_pty(channel) + data = ['pty-req', false] + data += Net::SSH::Connection::Channel::VALID_PTY_OPTIONS.merge(:modes => "\0").values + events << LocalPacket.new(:channel_request, channel.remote_id, *data) + end + # Scripts the reception of a channel data packet from the remote host by # the given Net::SSH::Test::Channel +channel+. This will typically be # called via Net::SSH::Test::Channel#gets_data. |