Skip to content

Commit 446ff3e

Browse files
committedMar 3, 2025·
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.
1 parent e6758ab commit 446ff3e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed
 

‎test/openssl/test_pkey_dh.rb

+11-16
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,20 @@ def test_new_generate
1818
assert_key(dh)
1919
end if ENV["OSSL_TEST_ALL"]
2020

21-
def test_new_break_on_non_fips
22-
omit_on_fips if !aws_lc?
23-
24-
assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break })
25-
assert_raise(RuntimeError) do
26-
OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise }
21+
def test_new_break
22+
unless openssl? && OpenSSL.fips_mode
23+
assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break })
24+
assert_raise(RuntimeError) do
25+
OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise }
26+
end
27+
else
28+
# The block argument is not executed in FIPS case.
29+
# See https://github.com/ruby/openssl/issues/692 for details.
30+
assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break })
31+
assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise })
2732
end
2833
end
2934

30-
def test_new_break_on_fips
31-
omit_on_non_fips
32-
return unless openssl? # This behavior only applies to OpenSSL.
33-
34-
# The block argument is not executed in FIPS case.
35-
# See https://github.com/ruby/openssl/issues/692 for details.
36-
assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break })
37-
assert(OpenSSL::PKey::DH.new(NEW_KEYLEN) { raise })
38-
end
39-
4035
def test_derive_key
4136
params = Fixtures.pkey("dh2048_ffdhe2048")
4237
dh1 = OpenSSL::PKey.generate_key(params)

0 commit comments

Comments
 (0)