From 224e284fa1694073117428d6eee49d7f88516c69 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Sat, 8 Jun 2019 17:47:12 -0400 Subject: Travis' PyPy variants' local SSL doesn't support Curve25519 But really, this is necessary for any such platform/ssl version --- tests/test_kex.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/test_kex.py b/tests/test_kex.py index 456a213f..70746157 100644 --- a/tests/test_kex.py +++ b/tests/test_kex.py @@ -128,23 +128,25 @@ class KexTest(unittest.TestCase): self._original_generate_key_pair = KexNistp256._generate_key_pair KexNistp256._generate_key_pair = dummy_generate_key_pair - static_x25519_key = x25519.X25519PrivateKey.from_private_bytes( - unhexlify( - b"2184abc7eb3e656d2349d2470ee695b570c227340c2b2863b6c9ff427af1f040" # noqa + if KexCurve25519.is_available(): + static_x25519_key = x25519.X25519PrivateKey.from_private_bytes( + unhexlify( + b"2184abc7eb3e656d2349d2470ee695b570c227340c2b2863b6c9ff427af1f040" # noqa + ) ) - ) - mock_x25519 = Mock() - mock_x25519.generate.return_value = static_x25519_key - patcher = patch( - "paramiko.kex_curve25519.X25519PrivateKey", mock_x25519 - ) - patcher.start() - self.x25519_patcher = patcher + mock_x25519 = Mock() + mock_x25519.generate.return_value = static_x25519_key + patcher = patch( + "paramiko.kex_curve25519.X25519PrivateKey", mock_x25519 + ) + patcher.start() + self.x25519_patcher = patcher def tearDown(self): os.urandom = self._original_urandom KexNistp256._generate_key_pair = self._original_generate_key_pair - self.x25519_patcher.stop() + if hasattr(self, "x25519_patcher"): + self.x25519_patcher.stop() def test_group1_client(self): transport = FakeTransport() -- cgit v1.2.3