summaryrefslogtreecommitdiff
path: root/test/net/imap
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-09 00:16:48 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-09 00:16:48 +0000
commitd2a9f00eccf95edf003d6ea562011f99ab5f5279 (patch)
tree808f861cc5a882f0daf5e621a36aab239c047dfb /test/net/imap
parente240f93f2174d80040d381ef889fcefb48e8378e (diff)
* test/net/imap/test_imap.rb: use IPv4 for
test_imaps_post_connection_check. [ruby-dev:41189] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/imap')
-rw-r--r--test/net/imap/test_imap.rb26
1 files changed, 17 insertions, 9 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 0ecd3e8de59..5cf2e973460 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -6,6 +6,8 @@ class IMAPTest < Test::Unit::TestCase
SERVER_KEY = File.expand_path("server.key", File.dirname(__FILE__))
SERVER_CERT = File.expand_path("server.crt", File.dirname(__FILE__))
+ SERVER_ADDR = "127.0.0.1"
+
def setup
@do_not_reverse_lookup = Socket.do_not_reverse_lookup
Socket.do_not_reverse_lookup = true
@@ -83,7 +85,9 @@ class IMAPTest < Test::Unit::TestCase
if defined?(OpenSSL)
assert_raise(OpenSSL::SSL::SSLError) do
imaps_test do |port|
- Net::IMAP.new("127.0.0.1",
+ # SERVER_ADDR is different from the hostname in the certificate,
+ # so the following code should raise a SSLError.
+ Net::IMAP.new(SERVER_ADDR,
:port => port,
:ssl => { :ca_file => CA_FILE })
end
@@ -107,7 +111,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_unexpected_eof
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
Thread.start do
begin
@@ -138,7 +142,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_idle
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
requests = []
Thread.start do
@@ -190,7 +194,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_exception_during_idle
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
requests = []
Thread.start do
@@ -255,7 +259,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_idle_done_not_during_idle
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
requests = []
Thread.start do
@@ -284,7 +288,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_unexpected_bye
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
Thread.start do
begin
@@ -312,7 +316,7 @@ class IMAPTest < Test::Unit::TestCase
end
def test_exception_during_shutdown
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
Thread.start do
begin
@@ -351,7 +355,7 @@ class IMAPTest < Test::Unit::TestCase
private
def imaps_test
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
ctx = OpenSSL::SSL::SSLContext.new
ctx.ca_file = CA_FILE
@@ -389,7 +393,7 @@ class IMAPTest < Test::Unit::TestCase
end
def starttls_test
- server = TCPServer.new(0)
+ server = create_tcp_server
port = server.addr[1]
Thread.start do
begin
@@ -428,4 +432,8 @@ class IMAPTest < Test::Unit::TestCase
server.close
end
end
+
+ def create_tcp_server
+ return TCPServer.new(SERVER_ADDR, 0)
+ end
end