aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pair.rb
diff options
context:
space:
mode:
authorZachary Scott <e@zzak.io>2015-07-22 18:29:46 -0400
committerZachary Scott <e@zzak.io>2015-07-22 18:29:46 -0400
commit4c033a312c39b233474da82068b2206f63e4d253 (patch)
tree2f472008449a5eeb18b5e34270b7d2c15f2f8ba1 /test/test_pair.rb
parentd7c29362d7c26024e8f6f29da927ec5ee2c0ac9d (diff)
downloadruby-openssl-4c033a312c39b233474da82068b2206f63e4d253.tar.gz
Skip this test if openssl was compiled without tmp_ecdh_callback
Diffstat (limited to 'test/test_pair.rb')
-rw-r--r--test/test_pair.rb66
1 files changed, 34 insertions, 32 deletions
diff --git a/test/test_pair.rb b/test/test_pair.rb
index d2fbf729..6ad57fed 100644
--- a/test/test_pair.rb
+++ b/test/test_pair.rb
@@ -283,43 +283,45 @@ module OpenSSL::TestPairM
serv.close if serv && !serv.closed?
end
- def test_ecdh_callback
- called = false
- ctx2 = OpenSSL::SSL::SSLContext.new
- ctx2.ciphers = "ECDH"
- ctx2.tmp_ecdh_callback = ->(*args) {
- called = true
- OpenSSL::PKey::EC.new "prime256v1"
- }
+ if OpenSSL::SSL::SSLContext.new.respond_to?(:tmp_ecdh_callback)
+ def test_ecdh_callback
+ called = false
+ ctx2 = OpenSSL::SSL::SSLContext.new
+ ctx2.ciphers = "ECDH"
+ ctx2.tmp_ecdh_callback = ->(*args) {
+ called = true
+ OpenSSL::PKey::EC.new "prime256v1"
+ }
- sock1, sock2 = tcp_pair
+ sock1, sock2 = tcp_pair
- s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2)
- ctx1 = OpenSSL::SSL::SSLContext.new
- ctx1.ciphers = "ECDH"
+ s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx2)
+ ctx1 = OpenSSL::SSL::SSLContext.new
+ ctx1.ciphers = "ECDH"
- s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
- th = Thread.new do
- begin
- rv = s1.connect_nonblock(exception: false)
- case rv
- when :wait_writable
- IO.select(nil, [s1], nil, 5)
- when :wait_readable
- IO.select([s1], nil, nil, 5)
- end
- end until rv == s1
- end
+ s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
+ th = Thread.new do
+ begin
+ rv = s1.connect_nonblock(exception: false)
+ case rv
+ when :wait_writable
+ IO.select(nil, [s1], nil, 5)
+ when :wait_readable
+ IO.select([s1], nil, nil, 5)
+ end
+ end until rv == s1
+ end
- accepted = s2.accept
+ accepted = s2.accept
- assert called, 'ecdh callback should be called'
- ensure
- s1.close if s1
- s2.close if s2
- sock1.close if sock1
- sock2.close if sock2
- accepted.close if accepted.respond_to?(:close)
+ assert called, 'ecdh callback should be called'
+ ensure
+ s1.close if s1
+ s2.close if s2
+ sock1.close if sock1
+ sock2.close if sock2
+ accepted.close if accepted.respond_to?(:close)
+ end
end
def test_connect_accept_nonblock_no_exception