From 5c07d7a87c54a8532b49ba41febe8d526e5734d8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 23 Jan 2019 22:00:14 -0500 Subject: Fixes #4734 -- Deal with deprecated things (#4736) * Fixes #4734 -- Deal with deprecated things - Make year based aliases of PersistentlyDeprecated so we can easily assess age - Removed encode/decode rfc6979 signature - Removed Certificate.serial * Unused import --- tests/hazmat/primitives/test_asym_utils.py | 13 +------------ tests/x509/test_x509.py | 21 --------------------- tests/x509/test_x509_ext.py | 12 ++++++------ 3 files changed, 7 insertions(+), 39 deletions(-) (limited to 'tests') diff --git a/tests/hazmat/primitives/test_asym_utils.py b/tests/hazmat/primitives/test_asym_utils.py index fc9e9fd8..d817c651 100644 --- a/tests/hazmat/primitives/test_asym_utils.py +++ b/tests/hazmat/primitives/test_asym_utils.py @@ -7,19 +7,8 @@ from __future__ import absolute_import, division, print_function import pytest from cryptography.hazmat.primitives.asymmetric.utils import ( - Prehashed, decode_dss_signature, decode_rfc6979_signature, - encode_dss_signature, encode_rfc6979_signature, + Prehashed, decode_dss_signature, encode_dss_signature ) -from cryptography.utils import CryptographyDeprecationWarning - - -def test_deprecated_rfc6979_signature(): - with pytest.warns(CryptographyDeprecationWarning): - sig = encode_rfc6979_signature(1, 1) - assert sig == b"0\x06\x02\x01\x01\x02\x01\x01" - with pytest.warns(CryptographyDeprecationWarning): - decoded = decode_rfc6979_signature(sig) - assert decoded == (1, 1) def test_dss_signature(): diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index c8c863fb..1ead5947 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -609,27 +609,6 @@ class TestRSACertificate(object): SignatureAlgorithmOID._RSA_WITH_SHA1 ) - def test_cert_serial_number(self, backend): - cert = _load_cert( - os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"), - x509.load_der_x509_certificate, - backend - ) - - with pytest.warns(utils.CryptographyDeprecationWarning): - assert cert.serial == 2 - assert cert.serial_number == 2 - - def test_cert_serial_warning(self, backend): - cert = _load_cert( - os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"), - x509.load_der_x509_certificate, - backend - ) - - with pytest.warns(utils.CryptographyDeprecationWarning): - cert.serial - def test_load_der_cert(self, backend): cert = _load_cert( os.path.join("x509", "PKITS_data", "certs", "GoodCACert.crt"), diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index 6de105fa..6cf388da 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -1673,11 +1673,11 @@ class TestKeyUsageExtension(object): class TestDNSName(object): def test_init_deprecated(self): pytest.importorskip("idna") - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): name = x509.DNSName(u".\xf5\xe4\xf6\xfc.example.com") assert name.value == u".xn--4ca7aey.example.com" - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): name = x509.DNSName(u"\xf5\xe4\xf6\xfc.example.com") assert name.value == u"xn--4ca7aey.example.com" @@ -1792,7 +1792,7 @@ class TestRFC822Name(object): def test_idna(self): pytest.importorskip("idna") - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): gn = x509.RFC822Name(u"email@em\xe5\xefl.com") assert gn.value == u"email@xn--eml-vla4c.com" @@ -1832,7 +1832,7 @@ class TestUniformResourceIdentifier(object): def test_idna_no_port(self): pytest.importorskip("idna") - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): gn = x509.UniformResourceIdentifier( u"http://\u043f\u044b\u043a\u0430.cryptography" ) @@ -1841,7 +1841,7 @@ class TestUniformResourceIdentifier(object): def test_idna_with_port(self): pytest.importorskip("idna") - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): gn = x509.UniformResourceIdentifier( u"gopher://\u043f\u044b\u043a\u0430.cryptography:70/some/path" ) @@ -1856,7 +1856,7 @@ class TestUniformResourceIdentifier(object): def test_query_and_fragment(self): pytest.importorskip("idna") - with pytest.warns(utils.DeprecatedIn21): + with pytest.warns(utils.CryptographyDeprecationWarning): gn = x509.UniformResourceIdentifier( u"ldap://\u043f\u044b\u043a\u0430.cryptography:90/path?query=" u"true#somedata" -- cgit v1.2.3