diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2019-06-08 17:47:12 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2019-06-08 17:49:32 -0400 |
commit | 224e284fa1694073117428d6eee49d7f88516c69 (patch) | |
tree | c37e9c4d32db7ab80dce3cb9c6e771ad2f998b53 /tests | |
parent | 5c0dc5b6ceb182115ad646ccca52707f5cfca4f0 (diff) |
Travis' PyPy variants' local SSL doesn't support Curve25519
But really, this is necessary for any such platform/ssl version
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_kex.py | 26 |
1 files changed, 14 insertions, 12 deletions
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() |