diff --git a/test/openssl/engine_utils.rb b/test/openssl/engine_utils.rb new file mode 100644 index 000000000..4b5e2e631 --- /dev/null +++ b/test/openssl/engine_utils.rb @@ -0,0 +1,12 @@ +module EngineUtils + def get_engine + OpenSSL::Engine.by_id("openssl") + end + + def crypt_data(data, key, mode) + cipher = yield + cipher.send mode + cipher.key = key + cipher.update(data) + cipher.final + end +end diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb index 1ede6ed08..ec56c5ab8 100644 --- a/test/openssl/test_engine.rb +++ b/test/openssl/test_engine.rb @@ -74,8 +74,8 @@ def test_openssl_engine_cipher_rc4 # this is required because OpenSSL::Engine methods change global state def with_openssl(code, **opts) assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;", **opts) - require #{__FILE__.dump} - include OpenSSL::TestEngine::Utils + require 'engine_utils' + include EngineUtils #{code} end; end diff --git a/test/openssl/test_fips.rb b/test/openssl/test_fips.rb index 8cd474f9a..03f7761a0 100644 --- a/test/openssl/test_fips.rb +++ b/test/openssl/test_fips.rb @@ -12,8 +12,6 @@ def test_fips_mode_is_reentrant def test_fips_mode_get return unless OpenSSL::OPENSSL_FIPS assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;") - require #{__FILE__.dump} - begin OpenSSL.fips_mode = true assert OpenSSL.fips_mode == true, ".fips_mode returns true when .fips_mode=true"