From 4157fe7ed01842222456c34490588a4d5dfef9c4 Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Tue, 30 Jan 2024 15:38:33 -0700 Subject: [PATCH] Add changelog --- changelog/65954.fixed.md | 1 + salt/utils/rsax931.py | 1 - tests/pytests/unit/utils/test_rsax931.py | 26 ++++++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 changelog/65954.fixed.md diff --git a/changelog/65954.fixed.md b/changelog/65954.fixed.md new file mode 100644 index 00000000000..113d603e005 --- /dev/null +++ b/changelog/65954.fixed.md @@ -0,0 +1 @@ +Fixed issue where Salt can't find libcrypto when pip installed from a cloned repo diff --git a/salt/utils/rsax931.py b/salt/utils/rsax931.py index 05b4c9470a4..350655c56f7 100644 --- a/salt/utils/rsax931.py +++ b/salt/utils/rsax931.py @@ -2,7 +2,6 @@ Create and verify ANSI X9.31 RSA signatures using OpenSSL libcrypto """ - import ctypes.util import glob import os diff --git a/tests/pytests/unit/utils/test_rsax931.py b/tests/pytests/unit/utils/test_rsax931.py index 0f2b9499bc6..39bdb7cac30 100644 --- a/tests/pytests/unit/utils/test_rsax931.py +++ b/tests/pytests/unit/utils/test_rsax931.py @@ -1,7 +1,6 @@ """ Test the RSA ANSI X9.31 signer and verifier """ - import ctypes import ctypes.util import fnmatch @@ -19,7 +18,7 @@ from salt.utils.rsax931 import ( _find_libcrypto, _load_libcrypto, ) -from tests.support.mock import patch, MagicMock +from tests.support.mock import patch @pytest.fixture @@ -215,6 +214,7 @@ def test_find_libcrypto_darwin_catalina(): assert "/usr/lib/libcrypto.44.dylib" == lib_path +@pytest.mark.skip_unless_on_darwin def test_find_libcrypto_darwin_pip_install(): """ Test _find_libcrypto on a macOS host where there salt has been installed @@ -223,15 +223,17 @@ def test_find_libcrypto_darwin_pip_install(): bin_path = "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10" expected = "/Library/Frameworks/Python.framework/Versions/3.10/lib/libcrypto.dylib" glob_effect = ([], [], ["yay"], [], [], [], []) - with patch("salt.utils.platform.is_darwin", lambda: True),\ - patch("sys.executable", bin_path),\ - patch("os.path.islink", return_value=False),\ - patch.object(glob, "glob", side_effect=glob_effect) as mock_glob: + with patch("salt.utils.platform.is_darwin", lambda: True), patch( + "sys.executable", bin_path + ), patch("os.path.islink", return_value=False), patch.object( + glob, "glob", side_effect=glob_effect + ) as mock_glob: lib_path = _find_libcrypto() assert lib_path == "yay" mock_glob.assert_any_call(expected) +@pytest.mark.skip_unless_on_darwin def test_find_libcrypto_darwin_pip_install_venv(): """ Test _find_libcrypto on a macOS host where there salt has been installed @@ -241,11 +243,13 @@ def test_find_libcrypto_darwin_pip_install_venv(): lnk_path = "/Users/bill/src/salt/venv/bin/python" expected = "/Library/Frameworks/Python.framework/Versions/3.10/lib/libcrypto.dylib" glob_effect = ([], [], ["yay"], [], [], [], []) - with patch("salt.utils.platform.is_darwin", lambda: True), \ - patch("sys.executable", lnk_path), \ - patch("os.path.islink", return_value=True), \ - patch("os.path.realpath", return_value=src_path), \ - patch.object(glob, "glob", side_effect=glob_effect) as mock_glob: + with patch("salt.utils.platform.is_darwin", lambda: True), patch( + "sys.executable", lnk_path + ), patch("os.path.islink", return_value=True), patch( + "os.path.realpath", return_value=src_path + ), patch.object( + glob, "glob", side_effect=glob_effect + ) as mock_glob: lib_path = _find_libcrypto() assert lib_path == "yay" mock_glob.assert_any_call(expected)