From 318942867e04bc1401d8957a51072a4a79a24957 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 21 Jun 2015 21:46:41 -0500 Subject: add eq/ne support to NameConstraints --- src/cryptography/x509.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py index 4dbe3da1..1d705e70 100644 --- a/src/cryptography/x509.py +++ b/src/cryptography/x509.py @@ -709,6 +709,18 @@ class NameConstraints(object): self._permitted_subtrees = permitted_subtrees self._excluded_subtrees = excluded_subtrees + def __eq__(self, other): + if not isinstance(other, NameConstraints): + return NotImplemented + + return ( + self.excluded_subtrees == other.excluded_subtrees and + self.permitted_subtrees == other.permitted_subtrees + ) + + def __ne__(self, other): + return not self == other + def _validate_ip_name(self, tree): if any(isinstance(name, IPAddress) and not isinstance( name.value, (ipaddress.IPv4Network, ipaddress.IPv6Network) -- cgit v1.2.3