Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_provider.rb in FIPS. #794

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Rake::TestTask.new(:test_fips_internal) do |t|
'test/openssl/test_pkey_dsa.rb',
'test/openssl/test_pkey_ec.rb',
'test/openssl/test_pkey_rsa.rb',
'test/openssl/test_provider.rb',
]
t.warning = true
end
Expand Down
25 changes: 18 additions & 7 deletions test/openssl/test_provider.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative 'utils'
if defined?(OpenSSL) && defined?(OpenSSL::Provider) && !OpenSSL.fips_mode
if defined?(OpenSSL) && defined?(OpenSSL::Provider)

class OpenSSL::TestProvider < OpenSSL::TestCase
def test_openssl_provider_name_inspect
Expand All @@ -12,14 +12,22 @@ def test_openssl_provider_name_inspect
end

def test_openssl_provider_names
# We expect the following providers are loaded in the cases:
# * Non-FIPS: default
# * FIPS: fips, base
# Use the null provider to test the added provider.
# See provider(7) - OPENSSL PROVIDERS to see the list of providers, and
# OSSL_PROVIDER-null(7) to check the details of the null provider.
with_openssl <<-'end;'
base_provider = OpenSSL::Provider.load("base")
assert_equal(2, OpenSSL::Provider.provider_names.size)
assert_includes(OpenSSL::Provider.provider_names, "base")
num = OpenSSL::Provider.provider_names.size

assert_equal(true, base_provider.unload)
assert_equal(1, OpenSSL::Provider.provider_names.size)
assert_not_includes(OpenSSL::Provider.provider_names, "base")
added_provider = OpenSSL::Provider.load("null")
assert_equal(num + 1, OpenSSL::Provider.provider_names.size)
assert_includes(OpenSSL::Provider.provider_names, "null")

assert_equal(true, added_provider.unload)
assert_equal(num, OpenSSL::Provider.provider_names.size)
assert_not_includes(OpenSSL::Provider.provider_names, "null")
junaruga marked this conversation as resolved.
Show resolved Hide resolved
end;
end

Expand All @@ -33,6 +41,9 @@ def test_unloaded_openssl_provider
end

def test_openssl_legacy_provider
# The legacy provider is not supported on FIPS.
omit_on_fips

with_openssl(<<-'end;')
begin
OpenSSL::Provider.load("legacy")
Expand Down