From e00bad5332f3ba851823270bee8e191ac0fc4ec2 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 13 Sep 2017 08:29:19 +0800 Subject: compare against bytes values, not the U-label decoded ones (#3906) We need to add one small test to cover a case that is no longer covered with this switch. --- src/cryptography/x509/general_name.py | 4 ++-- tests/x509/test_x509_ext.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py index 114b43ae..abf3a48a 100644 --- a/src/cryptography/x509/general_name.py +++ b/src/cryptography/x509/general_name.py @@ -117,7 +117,7 @@ class RFC822Name(object): if not isinstance(other, RFC822Name): return NotImplemented - return self.value == other.value + return self.bytes_value == other.bytes_value def __ne__(self, other): return not self == other @@ -300,7 +300,7 @@ class UniformResourceIdentifier(object): if not isinstance(other, UniformResourceIdentifier): return NotImplemented - return self.value == other.value + return self.bytes_value == other.bytes_value def __ne__(self, other): return not self == other diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index 5b9fb347..830283bb 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -1669,6 +1669,11 @@ class TestUniformResourceIdentifier(object): b"gopher://xn--80ato2c.cryptography:70/some/path" ) + def test_empty_string(self): + gn = x509.UniformResourceIdentifier(b"") + with pytest.warns(utils.DeprecatedIn21): + assert gn.value == u"" + def test_query_and_fragment(self): gn = x509.UniformResourceIdentifier( b"ldap://cryptography:90/path?query=true#somedata" -- cgit v1.2.3