aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_dsa.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_dsa.py')
-rw-r--r--tests/hazmat/primitives/test_dsa.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py
index f818f73b..8c0fb80c 100644
--- a/tests/hazmat/primitives/test_dsa.py
+++ b/tests/hazmat/primitives/test_dsa.py
@@ -705,3 +705,67 @@ class TestDSANumbers(object):
with pytest.raises(TypeError):
dsa.DSAPrivateNumbers(x=None, public_numbers=public_numbers)
+
+
+class TestDSANumberEquality(object):
+ def test_parameter_numbers_eq(self):
+ param = dsa.DSAParameterNumbers(1, 2, 3)
+ assert param == dsa.DSAParameterNumbers(1, 2, 3)
+
+ def test_parameter_numbers_ne(self):
+ param = dsa.DSAParameterNumbers(1, 2, 3)
+ assert param != dsa.DSAParameterNumbers(1, 2, 4)
+ assert param != dsa.DSAParameterNumbers(1, 1, 3)
+ assert param != dsa.DSAParameterNumbers(2, 2, 3)
+ assert param != object()
+
+ def test_public_numbers_eq(self):
+ pub = dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 3))
+ assert pub == dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 3))
+
+ def test_public_numbers_ne(self):
+ pub = dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 3))
+ assert pub != dsa.DSAPublicNumbers(2, dsa.DSAParameterNumbers(1, 2, 3))
+ assert pub != dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(2, 2, 3))
+ assert pub != dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 3, 3))
+ assert pub != dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 4))
+ assert pub != object()
+
+ def test_private_numbers_eq(self):
+ pub = dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 3))
+ priv = dsa.DSAPrivateNumbers(1, pub)
+ assert priv == dsa.DSAPrivateNumbers(
+ 1, dsa.DSAPublicNumbers(
+ 1, dsa.DSAParameterNumbers(1, 2, 3)
+ )
+ )
+
+ def test_private_numbers_ne(self):
+ pub = dsa.DSAPublicNumbers(1, dsa.DSAParameterNumbers(1, 2, 3))
+ priv = dsa.DSAPrivateNumbers(1, pub)
+ assert priv != dsa.DSAPrivateNumbers(
+ 2, dsa.DSAPublicNumbers(
+ 1, dsa.DSAParameterNumbers(1, 2, 3)
+ )
+ )
+ assert priv != dsa.DSAPrivateNumbers(
+ 1, dsa.DSAPublicNumbers(
+ 2, dsa.DSAParameterNumbers(1, 2, 3)
+ )
+ )
+ assert priv != dsa.DSAPrivateNumbers(
+ 1, dsa.DSAPublicNumbers(
+ 1, dsa.DSAParameterNumbers(2, 2, 3)
+ )
+ )
+ assert priv != dsa.DSAPrivateNumbers(
+ 1, dsa.DSAPublicNumbers(
+ 1, dsa.DSAParameterNumbers(1, 3, 3)
+ )
+ )
+ assert priv != dsa.DSAPrivateNumbers(
+ 1, dsa.DSAPublicNumbers(
+ 1, dsa.DSAParameterNumbers(1, 2, 4)
+ )
+ )
+ assert priv != object()