aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2019-11-24 18:16:14 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2019-11-25 07:16:14 +0800
commitaa7c2992c91ea90dc967e6acc6b2fb190aed0000 (patch)
tree00a7fed58428e1da1237d43482daaabd7b8d8ec3 /tests
parent86b4b391edbb1de734c2baed0939a111a420a6f4 (diff)
downloadcryptography-aa7c2992c91ea90dc967e6acc6b2fb190aed0000.tar.gz
cryptography-aa7c2992c91ea90dc967e6acc6b2fb190aed0000.tar.bz2
cryptography-aa7c2992c91ea90dc967e6acc6b2fb190aed0000.zip
Fixes #5065 -- skip serialization tests which use RC2 if OpenSSL doesn't have RC2 (#5072)
* Refs #5065 -- have a CI job with OpenSSL built with no-rc2 * Fixes #5065 -- skip serialization tests which use RC2 if OpenSSL doesn't have RC2
Diffstat (limited to 'tests')
-rw-r--r--tests/hazmat/primitives/test_pkcs12.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/hazmat/primitives/test_pkcs12.py b/tests/hazmat/primitives/test_pkcs12.py
index f084d578..0bb76e25 100644
--- a/tests/hazmat/primitives/test_pkcs12.py
+++ b/tests/hazmat/primitives/test_pkcs12.py
@@ -10,6 +10,7 @@ import pytest
from cryptography import x509
from cryptography.hazmat.backends.interfaces import DERSerializationBackend
+from cryptography.hazmat.backends.openssl.backend import _RC2
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.hazmat.primitives.serialization.pkcs12 import (
load_key_and_certificates
@@ -20,16 +21,7 @@ from .utils import load_vectors_from_file
@pytest.mark.requires_backend_interface(interface=DERSerializationBackend)
class TestPKCS12(object):
- @pytest.mark.parametrize(
- ("filename", "password"),
- [
- ("cert-key-aes256cbc.p12", b"cryptography"),
- ("cert-none-key-none.p12", b"cryptography"),
- ("cert-rc2-key-3des.p12", b"cryptography"),
- ("no-password.p12", None),
- ]
- )
- def test_load_pkcs12_ec_keys(self, filename, password, backend):
+ def _test_load_pkcs12_ec_keys(self, filename, password, backend):
cert = load_vectors_from_file(
os.path.join("x509", "custom", "ca", "ca.pem"),
lambda pemfile: x509.load_pem_x509_certificate(
@@ -52,6 +44,30 @@ class TestPKCS12(object):
assert parsed_key.private_numbers() == key.private_numbers()
assert parsed_more_certs == []
+ @pytest.mark.parametrize(
+ ("filename", "password"),
+ [
+ ("cert-key-aes256cbc.p12", b"cryptography"),
+ ("cert-none-key-none.p12", b"cryptography"),
+ ]
+ )
+ def test_load_pkcs12_ec_keys(self, filename, password, backend):
+ self._test_load_pkcs12_ec_keys(filename, password, backend)
+
+ @pytest.mark.parametrize(
+ ("filename", "password"),
+ [
+ ("cert-rc2-key-3des.p12", b"cryptography"),
+ ("no-password.p12", None),
+ ]
+ )
+ @pytest.mark.supported(
+ only_if=lambda backend: backend.cipher_supported(_RC2(), None),
+ skip_message="Does not support RC2"
+ )
+ def test_load_pkcs12_ec_keys_rc2(self, filename, password, backend):
+ self._test_load_pkcs12_ec_keys(filename, password, backend)
+
def test_load_pkcs12_cert_only(self, backend):
cert = load_vectors_from_file(
os.path.join("x509", "custom", "ca", "ca.pem"),