From cc4a42dbc56974c10bf8dc0aca67ab29cccd2f77 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 4 Jan 2014 13:32:56 -0600 Subject: Add initial CommonCrypto bindings (no backend yet) --- tests/hazmat/bindings/test_commoncrypto.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/hazmat/bindings/test_commoncrypto.py (limited to 'tests') diff --git a/tests/hazmat/bindings/test_commoncrypto.py b/tests/hazmat/bindings/test_commoncrypto.py new file mode 100644 index 00000000..385eeeb6 --- /dev/null +++ b/tests/hazmat/bindings/test_commoncrypto.py @@ -0,0 +1,25 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from cryptography.hazmat.bindings.commoncrypto.binding import Binding + + +@pytest.mark.commoncrypto +class TestCommonCrypto(object): + def test_binding_loads(self): + binding = Binding() + assert binding + assert binding.lib + assert binding.ffi -- cgit v1.2.3 From 5001c3f7479ff28457948a582e5e7446ac838ca6 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 4 Jan 2014 13:56:19 -0600 Subject: cover a missing branch in the commoncrypto bindings --- tests/hazmat/bindings/test_commoncrypto.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/bindings/test_commoncrypto.py b/tests/hazmat/bindings/test_commoncrypto.py index 385eeeb6..1eb71151 100644 --- a/tests/hazmat/bindings/test_commoncrypto.py +++ b/tests/hazmat/bindings/test_commoncrypto.py @@ -13,13 +13,19 @@ import pytest -from cryptography.hazmat.bindings.commoncrypto.binding import Binding - @pytest.mark.commoncrypto class TestCommonCrypto(object): def test_binding_loads(self): + from cryptography.hazmat.bindings.commoncrypto.binding import Binding binding = Binding() assert binding assert binding.lib assert binding.ffi + + def test_binding_returns_same_lib(self): + from cryptography.hazmat.bindings.commoncrypto.binding import Binding + binding = Binding() + binding2 = Binding() + assert binding.lib == binding2.lib + assert binding.ffi == binding2.ffi -- cgit v1.2.3 From 5e612d0ac078bae569dece5f718166a834fa9f7e Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 4 Jan 2014 19:42:36 -0600 Subject: add is_available() to CommonCrypto binding, use it for skipif --- tests/hazmat/bindings/test_commoncrypto.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/bindings/test_commoncrypto.py b/tests/hazmat/bindings/test_commoncrypto.py index 1eb71151..db3d1b74 100644 --- a/tests/hazmat/bindings/test_commoncrypto.py +++ b/tests/hazmat/bindings/test_commoncrypto.py @@ -13,18 +13,19 @@ import pytest +from cryptography.hazmat.bindings.commoncrypto.binding import Binding -@pytest.mark.commoncrypto + +@pytest.mark.skipif(not Binding.is_available(), + reason="CommonCrypto not available") class TestCommonCrypto(object): def test_binding_loads(self): - from cryptography.hazmat.bindings.commoncrypto.binding import Binding binding = Binding() assert binding assert binding.lib assert binding.ffi def test_binding_returns_same_lib(self): - from cryptography.hazmat.bindings.commoncrypto.binding import Binding binding = Binding() binding2 = Binding() assert binding.lib == binding2.lib -- cgit v1.2.3