[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
This commit is contained in:
Jun Aruga 2025-03-03 14:28:12 +01:00 committed by git
parent 12e2dfdc56
commit 9ccba88160

View File

@ -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)