From c37952cfce28ffe513352569186412a1ddaaabbd Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 7 Nov 2014 09:59:40 -0300 Subject: We can test this, we have the power! Fixes #874 --- cryptography/hazmat/bindings/openssl/binding.py | 21 ++++++++++++--------- tests/hazmat/bindings/test_openssl.py | 6 +++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py index 314c5147..c2256214 100644 --- a/cryptography/hazmat/bindings/openssl/binding.py +++ b/cryptography/hazmat/bindings/openssl/binding.py @@ -95,15 +95,7 @@ class Binding(object): # OpenSSL goes by a different library name on different operating # systems. - if sys.platform != "win32": - # In some circumstances, the order in which these libs are - # specified on the linker command-line is significant; - # libssl must come before libcrypto - # (http://marc.info/?l=openssl-users&m=135361825921871) - libraries = ["ssl", "crypto"] - else: # pragma: no cover - link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static") - libraries = _get_windows_libraries(link_type) + libraries = _get_libraries(sys.platform) cls.ffi, cls.lib = build_ffi_for_binding( module_prefix=cls._module_prefix, @@ -156,6 +148,17 @@ class Binding(object): ) +def _get_libraries(platform): + if platform != "win32": + # In some circumstances, the order in which these libs are + # specified on the linker command-line is significant; + # libssl must come before libcrypto + # (http://marc.info/?l=openssl-users&m=135361825921871) + return ["ssl", "crypto"] + else: + link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static") + return _get_windows_libraries(link_type) + def _get_windows_libraries(link_type): if link_type == "dynamic": return ["libeay32", "ssleay32", "advapi32"] diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index 78da965f..f68b680e 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -16,7 +16,7 @@ from __future__ import absolute_import, division, print_function import pytest from cryptography.hazmat.bindings.openssl.binding import ( - Binding, _get_windows_libraries + Binding, _get_libraries, _get_windows_libraries ) @@ -143,6 +143,10 @@ class TestOpenSSL(object): assert resp == expected_options assert b.lib.SSL_get_mode(ssl) == expected_options + def test_libraries(self): + assert _get_libraries("darwin") == ["ssl", "crypto"] + assert "ssleay32mt" in _get_libraries("win32") + def test_windows_static_dynamic_libraries(self): assert "ssleay32mt" in _get_windows_libraries("static") -- cgit v1.2.3 From 8a571452490df0f234720d3622ec2bb0f23e1c45 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 7 Nov 2014 09:59:58 -0300 Subject: No pragma, no problem! --- .coveragerc | 1 - 1 file changed, 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 58a1992d..8964f1cd 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,6 +6,5 @@ source = [report] exclude_lines = - pragma: no cover @abc.abstractmethod @abc.abstractproperty -- cgit v1.2.3 From 34dd58587ed443364a4ef8c82472a0bce1d447e6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 7 Nov 2014 10:01:19 -0300 Subject: appease the flake8 in the sky --- cryptography/hazmat/bindings/openssl/binding.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py index c2256214..056785dc 100644 --- a/cryptography/hazmat/bindings/openssl/binding.py +++ b/cryptography/hazmat/bindings/openssl/binding.py @@ -159,6 +159,7 @@ def _get_libraries(platform): link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static") return _get_windows_libraries(link_type) + def _get_windows_libraries(link_type): if link_type == "dynamic": return ["libeay32", "ssleay32", "advapi32"] -- cgit v1.2.3