diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-07-10 23:25:17 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-07-10 23:25:17 +0900 |
commit | ffc3781d219bae041929eb65b63b416673b7db32 (patch) | |
tree | 160f49668783cddcab8d49179dedd7d783b34a1d | |
parent | 9d5c823c07b576a4cce55d75392064182b2ec3bc (diff) | |
download | ruby-openssl-ffc3781d219bae041929eb65b63b416673b7db32.tar.gz |
Suppress warnings in tests
-rw-r--r-- | test/test_cipher.rb | 10 | ||||
-rw-r--r-- | test/test_pair.rb | 18 | ||||
-rw-r--r-- | test/test_ssl.rb | 28 |
3 files changed, 28 insertions, 28 deletions
diff --git a/test/test_cipher.rb b/test/test_cipher.rb index 81b4c45d..ada1fb26 100644 --- a/test/test_cipher.rb +++ b/test/test_cipher.rb @@ -5,16 +5,12 @@ if defined?(OpenSSL::TestUtils) class OpenSSL::TestCipher < OpenSSL::TestCase + @ciphers = OpenSSL::Cipher.ciphers + class << self def has_cipher?(name) - ciphers = OpenSSL::Cipher.ciphers - # redefine method so we can use the cached ciphers value from the closure - # and need not recompute the list each time - define_singleton_method :has_cipher? do |name| - ciphers.include?(name) - end - has_cipher?(name) + @ciphers.include?(name) end def has_ciphers?(list) diff --git a/test/test_pair.rb b/test/test_pair.rb index 575cb6c1..cf9b9303 100644 --- a/test/test_pair.rb +++ b/test/test_pair.rb @@ -330,7 +330,7 @@ module OpenSSL::TestPairM ctx2.tmp_dh_callback = nil sock1, sock2 = tcp_pair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) - accepted = s2.accept_nonblock(exception: false) + s2.accept_nonblock(exception: false) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" @@ -339,16 +339,16 @@ module OpenSSL::TestPairM s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) t = Thread.new { s1.connect } - accept = s2.accept + EnvUtil.suppress_warning { # uses default callback + assert_nothing_raised { s2.accept } + } assert_equal s1, t.value - assert accept ensure t.join if t s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 - accepted.close if accepted.respond_to?(:close) end def test_connect_without_setting_dh_callback @@ -357,7 +357,7 @@ module OpenSSL::TestPairM ctx2.security_level = 0 sock1, sock2 = tcp_pair s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) - accepted = s2.accept_nonblock(exception: false) + s2.accept_nonblock(exception: false) ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ciphers = "DH" @@ -365,16 +365,16 @@ module OpenSSL::TestPairM s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) t = Thread.new { s1.connect } - accept = s2.accept + EnvUtil.suppress_warning { # default DH + assert_nothing_raised { s2.accept } + } assert_equal s1, t.value - assert accept ensure t.join if t s1.close if s1 s2.close if s2 sock1.close if sock1 sock2.close if sock2 - accepted.close if accepted.respond_to?(:close) end def test_ecdh_callback @@ -411,7 +411,7 @@ module OpenSSL::TestPairM end until rv == s1 end - accepted = s2.accept + s2.accept assert called, 'ecdh callback should be called' rescue OpenSSL::SSL::SSLError => e if e.message =~ /no cipher match/ diff --git a/test/test_ssl.rb b/test/test_ssl.rb index e7f3348c..a8d6539f 100644 --- a/test/test_ssl.rb +++ b/test/test_ssl.rb @@ -687,11 +687,11 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase hostname = 'example.org' ctx3 = OpenSSL::SSL::SSLContext.new - ctx3.ciphers = "DH" + ctx3.ciphers = "aNULL" + ctx3.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx3.security_level = 0 ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| ctx3 } sock1, sock2 = socketpair @@ -699,7 +699,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ciphers = "DH" + ctx1.ciphers = "aNULL" ctx1.security_level = 0 s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) @@ -722,7 +722,8 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ciphers = "DH" + ctx2.ciphers = "aNULL" + ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx2.security_level = 0 ctx2.servername_cb = lambda { |args| Object.new } @@ -731,7 +732,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ciphers = "DH" + ctx1.ciphers = "aNULL" ctx1.security_level = 0 s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) @@ -756,12 +757,12 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase hostname = 'example.org' ctx3 = OpenSSL::SSL::SSLContext.new - ctx3.ciphers = "DH" + ctx3.ciphers = "aNULL" + ctx3.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx3.security_level = 0 assert_not_predicate ctx3, :frozen? ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ciphers = "DH" ctx2.servername_cb = lambda { |args| ctx3 } sock1, sock2 = socketpair @@ -769,7 +770,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ciphers = "DH" + ctx1.ciphers = "aNULL" ctx1.security_level = 0 s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) @@ -791,7 +792,8 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ciphers = "DH" + ctx2.ciphers = "aNULL" + ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx2.security_level = 0 ctx2.servername_cb = lambda { |args| nil } @@ -800,7 +802,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ciphers = "DH" + ctx1.ciphers = "aNULL" ctx1.security_level = 0 s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) @@ -823,7 +825,8 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase hostname = 'example.org' ctx2 = OpenSSL::SSL::SSLContext.new - ctx2.ciphers = "DH" + ctx2.ciphers = "aNULL" + ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx2.security_level = 0 ctx2.servername_cb = lambda do |args| cb_socket = args[0] @@ -836,7 +839,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2) ctx1 = OpenSSL::SSL::SSLContext.new - ctx1.ciphers = "DH" + ctx1.ciphers = "aNULL" ctx1.security_level = 0 s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1) @@ -1182,6 +1185,7 @@ end # test it doesn't cause a segmentation fault ctx = OpenSSL::SSL::SSLContext.new ctx.ciphers = "aNULL" + ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } ctx.security_level = 0 sock1, sock2 = socketpair |