Skip to content

Commit 104d68f

Browse files
junarugaekohl
authored andcommitted
Add tests around setting min_version in SSLContext
1 parent ae215a4 commit 104d68f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/openssl/test_ssl.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,27 @@ def test_sslctx_set_params
556556
ctx.options & OpenSSL::SSL::OP_NO_COMPRESSION
557557
end
558558

559+
def test_sslctx_set_params_min_version_on_greater_than_equal_openssl_11
560+
omit 'Omit in OpenSSL 1.0 or earlier versions' unless openssl?(1, 1, 0)
561+
omit 'Omit in LibreSSL' if libressl?
562+
563+
ctx = OpenSSL::SSL::SSLContext.new
564+
ctx.set_params
565+
566+
# The cached value should not exist.
567+
assert_raise(NoMethodError) { ctx.send(:@min_proto_version) }
568+
end
569+
570+
def test_sslctx_set_params_min_version_on_less_than_openssl_11
571+
omit 'Omit in OpenSSL 1.1 or later versions' if openssl?(1, 1, 0)
572+
573+
ctx = OpenSSL::SSL::SSLContext.new
574+
ctx.set_params
575+
576+
# This is not publicly exposed, but read the cached version.
577+
assert_equal OpenSSL::SSL::TLS1_VERSION, ctx.send(:@min_proto_version)
578+
end
579+
559580
def test_post_connect_check_with_anon_ciphers
560581
ctx_proc = -> ctx {
561582
ctx.ssl_version = :TLSv1_2

0 commit comments

Comments
 (0)