diff options
-rw-r--r-- | lib/net/ssh/test.rb | 5 | ||||
-rw-r--r-- | lib/net/ssh/test/script.rb | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/net/ssh/test.rb b/lib/net/ssh/test.rb index bc46a39..fe8f510 100644 --- a/lib/net/ssh/test.rb +++ b/lib/net/ssh/test.rb @@ -7,7 +7,8 @@ module Net; module SSH module Test def story - yield socket.script + yield socket.script if block_given? + return socket.script end def socket(options={}) @@ -22,7 +23,7 @@ module Net; module SSH @transport ||= Net::SSH::Transport::Session.new(options[:host] || "localhost", options.merge(:kex => "test", :host_key => "ssh-rsa", :paranoid => false, :proxy => socket(options))) end - def assert_script + def assert_scripted raise "there is no script to be processed" if socket.script.events.empty? yield assert socket.script.events.empty?, "there should not be any remaining scripted events, but there are still #{socket.script.events.length} pending" diff --git a/lib/net/ssh/test/script.rb b/lib/net/ssh/test/script.rb index 9be2617..69b5d92 100644 --- a/lib/net/ssh/test/script.rb +++ b/lib/net/ssh/test/script.rb @@ -11,12 +11,16 @@ module Net; module SSH; module Test @events = [] end - def opens_channel + def opens_channel(confirm=true) channel = Channel.new(self) channel.remote_id = 5555 events << LocalPacket.new(:channel_open) { |p| channel.local_id = p[:remote_id] } - events << RemotePacket.new(:channel_open_confirmation, channel.local_id, channel.remote_id, 0x20000, 0x10000) + + if confirm + events << RemotePacket.new(:channel_open_confirmation, channel.local_id, channel.remote_id, 0x20000, 0x10000) + end + channel end @@ -72,7 +76,7 @@ module Net; module SSH; module Test end def process(packet) - event = events.shift or raise "end of script reached, but got a packet type #{packet.type}" + event = events.shift or raise "end of script reached, but got a packet type #{packet.read_byte}" event.process(packet) end end |