summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Lane <rlane@vmware.com>2010-06-04 04:51:14 +0800
committer <net-ssh@solutious.com>2010-06-04 05:41:58 +0800
commit5a14ced30f922c3b4cae797c870a07ead7d1da20 (patch)
treeeb8aca8cc4870c343407c42f44574143c0f0373a /test
parent134af9733175494361a30272970c850f190fc797 (diff)
downloadnet-ssh-5a14ced30f922c3b4cae797c870a07ead7d1da20.tar.gz
delay CHANNEL_EOF packet until output buffer is empty
Previously, calling #eof! after #send_data would result in the CHANNEL_EOF packet being sent immediately, ahead of the data in the output buffer. Now buffer becomes empty.
Diffstat (limited to 'test')
-rw-r--r--test/connection/test_channel.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/connection/test_channel.rb b/test/connection/test_channel.rb
index 3600cf6..a80db3b 100644
--- a/test/connection/test_channel.rb
+++ b/test/connection/test_channel.rb
@@ -378,6 +378,7 @@ module Connection
channel.do_open_confirmation(0, 1000, 1000)
connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
channel.eof!
+ channel.process
end
def test_eof_bang_should_not_send_eof_if_eof_was_already_declared
@@ -385,6 +386,7 @@ module Connection
connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
channel.eof!
assert_nothing_raised { channel.eof! }
+ channel.process
end
def test_eof_q_should_return_true_if_eof_declared
@@ -394,15 +396,28 @@ module Connection
assert !channel.eof?
channel.eof!
assert channel.eof?
+ channel.process
end
def test_send_data_should_raise_exception_if_eof_declared
channel.do_open_confirmation(0, 1000, 1000)
connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
channel.eof!
+ channel.process
assert_raises(EOFError) { channel.send_data("die! die! die!") }
end
+ def test_data_should_precede_eof
+ channel.do_open_confirmation(0, 1000, 1000)
+ connection.expect do |t,p|
+ assert_equal CHANNEL_DATA, p.type
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
+ end
+ channel.send_data "foo"
+ channel.eof!
+ channel.process
+ end
+
private
class MockConnection