From 69c3348b7997cb5efc2bf55bb11ea32dc976dcba Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 6 Feb 2010 13:57:10 +0000 Subject: * lib/net/imap.rb (receive_responses): does not hang when an unexpected BYE response received. fixed [ruby-core:27944]. Thanks, Bob Potter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/imap/test_imap.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index f1471c0d0b..b7714dff1a 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -279,6 +279,34 @@ class IMAPTest < Test::Unit::TestCase end end + def test_unexpected_bye + server = TCPServer.new(0) + port = server.addr[1] + Thread.start do + begin + sock = server.accept + begin + sock.print("* OK Gimap ready for requests from 75.101.246.151 33if2752585qyk.26\r\n") + sock.gets + sock.print("* BYE System Error 33if2752585qyk.26\r\n") + ensure + sock.close + end + rescue + end + end + begin + begin + imap = Net::IMAP.new("localhost", :port => port) + assert_raise(Net::IMAP::ByeResponseError) do + imap.login("user", "password") + end + end + ensure + server.close + end + end + private def imaps_test -- cgit v1.2.3