Skip to content

Commit

Permalink
test_provider.rb: Make a legacy provider test optional.
Browse files Browse the repository at this point in the history
[ This is a backport to the 3.2 branch. ]

In some cases such as OpenSSL package in FreeBSD[1], the legacy provider is not
installed intentionally. So, we omit a test depending the legacy provider if the
legacy provider is not loadable.

For the test_openssl_provider_names test, we use base provider[2] instead of
legacy provider, because we would expect the base provider is always loadable
in OpenSSL 3 for now.

* [1] https://www.freshports.org/security/openssl/
* [2] https://wiki.openssl.org/index.php/OpenSSL_3.0#Providers

(cherry picked from commit 7223da7)
  • Loading branch information
junaruga authored and rhenium committed Nov 12, 2024
1 parent 509fc7f commit 1f07615
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/openssl/test_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def test_openssl_provider_name_inspect

def test_openssl_provider_names
with_openssl <<-'end;'
legacy_provider = OpenSSL::Provider.load("legacy")
base_provider = OpenSSL::Provider.load("base")
assert_equal(2, OpenSSL::Provider.provider_names.size)
assert_includes(OpenSSL::Provider.provider_names, "legacy")
assert_includes(OpenSSL::Provider.provider_names, "base")
assert_equal(true, legacy_provider.unload)
assert_equal(true, base_provider.unload)
assert_equal(1, OpenSSL::Provider.provider_names.size)
assert_not_includes(OpenSSL::Provider.provider_names, "legacy")
assert_not_includes(OpenSSL::Provider.provider_names, "base")
end;
end

Expand All @@ -34,7 +34,12 @@ def test_unloaded_openssl_provider

def test_openssl_legacy_provider
with_openssl(<<-'end;')
OpenSSL::Provider.load("legacy")
begin
OpenSSL::Provider.load("legacy")
rescue OpenSSL::Provider::ProviderError
omit "Only for OpenSSL with legacy provider"
end
algo = "RC4"
data = "a" * 1000
key = OpenSSL::Random.random_bytes(16)
Expand Down

0 comments on commit 1f07615

Please sign in to comment.