summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMiklos Fazkeas <mfazekas@szemafor.com>2014-12-02 00:50:48 +0100
committerMiklos Fazkeas <mfazekas@szemafor.com>2014-12-02 00:50:48 +0100
commitecb35da7dee0c80b1e32f8412e69f27750cd2b51 (patch)
treeba30e8723479375f41e8b19dba464d0b9141479d /test
parentad6a459121314bf2b71a12bf2bb18a1bcf3981d9 (diff)
downloadnet-ssh-ecb35da7dee0c80b1e32f8412e69f27750cd2b51.tar.gz
Implemented keepalive_maxcount
Diffstat (limited to 'test')
-rw-r--r--test/connection/test_session.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/connection/test_session.rb b/test/connection/test_session.rb
index 8af6cd3..268afb9 100644
--- a/test/connection/test_session.rb
+++ b/test/connection/test_session.rb
@@ -366,12 +366,29 @@ module Connection
def test_process_should_call_enqueue_message_if_io_select_timed_out
timeout = Net::SSH::Connection::Session::DEFAULT_IO_SELECT_TIMEOUT
options = { :keepalive => true }
- expected_packet = P(:byte, Net::SSH::Packet::IGNORE, :string, "keepalive")
+ expected_packet = P(:byte, Net::SSH::Packet::GLOBAL_REQUEST, :string, "keepalive@openssh.com", :bool, true)
IO.stubs(:select).with([socket],[],nil,timeout).returns(nil)
- transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
+ transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
session(options).process
end
+ def test_process_should_raise_if_keepalives_not_answered
+ timeout = Net::SSH::Connection::Session::DEFAULT_IO_SELECT_TIMEOUT
+ options = { :keepalive => true, :keepalive_interval => 300, :keepalive_maxcount => 3 }
+ expected_packet = P(:byte, Net::SSH::Packet::GLOBAL_REQUEST, :string, "keepalive@openssh.com", :bool, true)
+ [1,2,3].each do |i|
+ Time.stubs(:now).returns(i*300)
+ IO.stubs(:select).with([socket],[],nil,timeout).returns(nil)
+ transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
+ session(options).process
+ end
+
+ Time.stubs(:now).returns(4*300)
+ IO.stubs(:select).with([socket],[],nil,timeout).returns(nil)
+ transport.expects(:enqueue_message).with{ |msg| msg.content == expected_packet.content }
+ assert_raises(Net::SSH::Timeout) { session(options).process }
+ end
+
def test_process_should_not_call_enqueue_message_unless_io_select_timed_out
timeout = Net::SSH::Connection::Session::DEFAULT_IO_SELECT_TIMEOUT
options = { :keepalive => true }