summaryrefslogtreecommitdiffhomepage
path: root/tests/pkey.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pkey.py')
-rw-r--r--tests/pkey.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/pkey.py b/tests/pkey.py
index 25202a06..3a1ee5ca 100644
--- a/tests/pkey.py
+++ b/tests/pkey.py
@@ -1,3 +1,6 @@
+from pathlib import Path
+from unittest.mock import patch, call
+
from pytest import raises
from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey
@@ -28,6 +31,21 @@ class PKey_:
key = PKey.from_path(str(_support("rsa.key")))
assert isinstance(key, RSAKey)
+ @patch("paramiko.pkey.Path")
+ def expands_user(self, mPath):
+ # real key for guts that want a real key format
+ mykey = Path(_support("rsa.key"))
+ pathy = mPath.return_value.expanduser.return_value
+ # read_bytes for cryptography.io's loaders
+ pathy.read_bytes.return_value = mykey.read_bytes()
+ # open() for our own class loader
+ pathy.open.return_value = mykey.open()
+ # fake out exists() to avoid attempts to load cert
+ pathy.exists.return_value = False
+ PKey.from_path("whatever") # we're not testing expanduser itself
+ # Both key and cert paths
+ mPath.return_value.expanduser.assert_has_calls([call(), call()])
+
def raises_UnknownKeyType_for_unknown_types(self):
# I.e. a real, becomes a useful object via cryptography.io, key
# class that we do NOT support. Chose Ed448 randomly as OpenSSH