From fef35addb80d98c57894caeef420ef52e2fe0f72 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Sat, 1 Aug 2015 00:12:46 +0000 Subject: * ext/openssl/ossl_ssl.c (ossl_sslctx_setup): Implement SSLContext#options and options= using SSL_CTX_set_options and SSL_CTX_get_options. This reduces the number of ivars we need and simplifies `ossl_sslctx_setup`. * ext/openssl/lib/openssl/ssl.rb (module OpenSSL): Default `options` to SSL_OP_ALL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_ssl.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/openssl/test_ssl.rb') diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index d319ba9aaa..1d3e1b51aa 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -10,6 +10,34 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase assert_equal(ctx.setup, nil) end + def test_options_defaults_to_OP_ALL + ctx = OpenSSL::SSL::SSLContext.new + assert_equal OpenSSL::SSL::OP_ALL, ctx.options + end + + def test_setting_twice + ctx = OpenSSL::SSL::SSLContext.new + ctx.options = 4 + assert_equal 4, ctx.options + ctx.options = OpenSSL::SSL::OP_ALL + assert_equal OpenSSL::SSL::OP_ALL, ctx.options + end + + def test_options_setting_nil_means_all + ctx = OpenSSL::SSL::SSLContext.new + ctx.options = nil + assert_equal OpenSSL::SSL::OP_ALL, ctx.options + end + + def test_setting_options_raises_after_setup + ctx = OpenSSL::SSL::SSLContext.new + options = ctx.options + ctx.setup + assert_raises(RuntimeError) do + ctx.options = options + end + end + def test_ctx_setup_no_compression ctx = OpenSSL::SSL::SSLContext.new ctx.options = OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_COMPRESSION -- cgit v1.2.3