diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-09-14 11:14:28 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2017-09-13 23:14:28 -0400 |
commit | 83bb406138d344cce22c54ef3576516031c90ec6 (patch) | |
tree | 4a32104570b9a532e01ca8327906f3597ba0a7a9 /tests/x509/test_x509_ext.py | |
parent | 7b6be923e24481c2db75b3737a3ee07e7f3fb292 (diff) | |
download | cryptography-83bb406138d344cce22c54ef3576516031c90ec6.tar.gz cryptography-83bb406138d344cce22c54ef3576516031c90ec6.tar.bz2 cryptography-83bb406138d344cce22c54ef3576516031c90ec6.zip |
add __hash__ to PolicyConstraints and Extension (#3917)
Diffstat (limited to 'tests/x509/test_x509_ext.py')
-rw-r--r-- | tests/x509/test_x509_ext.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/x509/test_x509_ext.py b/tests/x509/test_x509_ext.py index 62ce9050..db805aa6 100644 --- a/tests/x509/test_x509_ext.py +++ b/tests/x509/test_x509_ext.py @@ -91,6 +91,25 @@ class TestExtension(object): assert ext1 != ext4 assert ext1 != object() + def test_hash(self): + ext1 = x509.Extension( + ExtensionOID.BASIC_CONSTRAINTS, + False, + x509.BasicConstraints(ca=False, path_length=None) + ) + ext2 = x509.Extension( + ExtensionOID.BASIC_CONSTRAINTS, + False, + x509.BasicConstraints(ca=False, path_length=None) + ) + ext3 = x509.Extension( + ExtensionOID.BASIC_CONSTRAINTS, + False, + x509.BasicConstraints(ca=True, path_length=None) + ) + assert hash(ext1) == hash(ext2) + assert hash(ext1) != hash(ext3) + class TestTLSFeature(object): def test_not_enum_type(self): @@ -2677,6 +2696,13 @@ class TestPolicyConstraints(object): assert pc != pc3 assert pc != object() + def test_hash(self): + pc = x509.PolicyConstraints(2, 1) + pc2 = x509.PolicyConstraints(2, 1) + pc3 = x509.PolicyConstraints(2, None) + assert hash(pc) == hash(pc2) + assert hash(pc) != hash(pc3) + @pytest.mark.requires_backend_interface(interface=RSABackend) @pytest.mark.requires_backend_interface(interface=X509Backend) |