From 9ccba88160c1b702a97b80817b97109cc2b9f33c Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Mon, 3 Mar 2025 14:28:12 +0100 Subject: [PATCH] [ruby/openssl] test_pkey_dh.rb: Merge 2 test_new_break tests to one test. Merge 2 test_new_break tests to one test because it's easy to maintain the test. https://github.com/ruby/openssl/commit/446ff3e11f --- test/openssl/test_pkey_dh.rb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb index fdb1b04424..cf56032cb3 100644 --- a/test/openssl/test_pkey_dh.rb +++ b/test/openssl/test_pkey_dh.rb @@ -18,25 +18,20 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase assert_key(dh) end if ENV["OSSL_TEST_ALL"] - def test_new_break_on_non_fips - omit_on_fips if !aws_lc? - - assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) - assert_raise(RuntimeError) do - OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise } + def test_new_break + unless openssl? && OpenSSL.fips_mode + assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) + assert_raise(RuntimeError) do + OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise } + end + else + # The block argument is not executed in FIPS case. + # See https://github.com/ruby/openssl/issues/692 for details. + assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) + assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise }) end end - def test_new_break_on_fips - omit_on_non_fips - return unless openssl? # This behavior only applies to OpenSSL. - - # The block argument is not executed in FIPS case. - # See https://github.com/ruby/openssl/issues/692 for details. - assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) - assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise }) - end - def test_derive_key params = Fixtures.pkey("dh2048_ffdhe2048") dh1 = OpenSSL::PKey.generate_key(params)