Skip to content

Commit

Permalink
Fix for review.
Browse files Browse the repository at this point in the history
  • Loading branch information
junaruga committed Mar 18, 2023
1 parent 3ffff4c commit aed2e77
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/openssl/test_fips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@

class OpenSSL::TestFIPS < OpenSSL::TestCase
def test_fips_mode_get_is_true_on_fips_mode_enabled
unless ENV["CI"] && ENV["TEST_RUBY_OPENSSL_FIPS_ENABLED"]
omit "Only for on FIPS mode environment on CI"
unless ENV["TEST_RUBY_OPENSSL_FIPS_ENABLED"]
omit "Only for FIPS mode environment"
end

assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;")
assert OpenSSL.fips_mode == true, ".fips_mode returns true on FIPS mode enabled"
assert OpenSSL.fips_mode == true, ".fips_mode should return true on FIPS mode enabled"
end;
end

def test_fips_mode_get_is_false_on_fips_mode_disabled
unless ENV["CI"] && !ENV["TEST_RUBY_OPENSSL_FIPS_ENABLED"]
omit "Only for non-FIPS mode environment on CI"
if ENV["TEST_RUBY_OPENSSL_FIPS_ENABLED"]
omit "Only for non-FIPS mode environment"
end

assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;")
assert OpenSSL.fips_mode == false, ".fips_mode returns false on FIPS mode disabled"
message = ".fips_mode should return false on FIPS mode disabled. " \
"If you run the test on FIPS mode, please set " \
"TEST_RUBY_OPENSSL_FIPS_ENABLED=true"
assert OpenSSL.fips_mode == false, message
end;
end

Expand All @@ -35,10 +38,10 @@ def test_fips_mode_get_with_fips_mode_set
assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;")
begin
OpenSSL.fips_mode = true
assert OpenSSL.fips_mode == true, ".fips_mode returns true when .fips_mode=true"
assert OpenSSL.fips_mode == true, ".fips_mode should return true when .fips_mode=true"
OpenSSL.fips_mode = false
assert OpenSSL.fips_mode == false, ".fips_mode returns false when .fips_mode=false"
assert OpenSSL.fips_mode == false, ".fips_mode should return false when .fips_mode=false"
rescue OpenSSL::OpenSSLError
pend "Could not set FIPS mode (OpenSSL::OpenSSLError: \#$!); skipping"
end
Expand Down

0 comments on commit aed2e77

Please sign in to comment.