summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2025-02-06 23:56:07 +0900
committergit <svn-admin@ruby-lang.org>2025-02-09 10:26:06 +0000
commit5791c93f8e16fedfcad861d83e9a54da05fd6154 (patch)
treef02d4b6109344629c8cba8c8f6de12a1af423dcc
parenta8b36314ec22d0f8bcbad855ba8dc675654301bf (diff)
[ruby/openssl] ssl: refactor test case test_verify_mode_server_cert
Minimize the amount of code inside the assert_raise block to avoid accidentally catching a wrong exception. https://github.com/ruby/openssl/commit/5089b2d311
-rw-r--r--test/openssl/test_ssl.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 711a94271b..f553cb1d93 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -348,27 +348,27 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
empty_store = OpenSSL::X509::Store.new
# Valid certificate, SSL_VERIFY_PEER
+ ctx = OpenSSL::SSL::SSLContext.new
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ ctx.cert_store = populated_store
assert_nothing_raised {
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
- ctx.cert_store = populated_store
server_connect(port, ctx) { |ssl| ssl.puts("abc"); ssl.gets }
}
# Invalid certificate, SSL_VERIFY_NONE
+ ctx = OpenSSL::SSL::SSLContext.new
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ ctx.cert_store = empty_store
assert_nothing_raised {
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
- ctx.cert_store = empty_store
server_connect(port, ctx) { |ssl| ssl.puts("abc"); ssl.gets }
}
# Invalid certificate, SSL_VERIFY_PEER
- assert_handshake_error {
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
- ctx.cert_store = empty_store
- server_connect(port, ctx) { |ssl| ssl.puts("abc"); ssl.gets }
+ ctx = OpenSSL::SSL::SSLContext.new
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ ctx.cert_store = empty_store
+ assert_raise(OpenSSL::SSL::SSLError) {
+ server_connect(port, ctx)
}
}
end