summaryrefslogtreecommitdiffhomepage
path: root/tests/test_sftp.py
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2005-07-18 05:43:44 +0000
committerRobey Pointer <robey@lag.net>2005-07-18 05:43:44 +0000
commitd8ee5e2a4a0e425320204a56d2470d56e228acda (patch)
treec9d7745669e59e7deabf7614c253b2d21f1dfd2e /tests/test_sftp.py
parente9ccd7ea209498b27a0b784936e2e8fb762202ed (diff)
[project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-46]
add SFTPFile.check and server support (and test) -- it's an sftp extension that allows a client to retrieve the hash of part or all of a file without downloading it. we're probably the only ones who implement it yet
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-xtests/test_sftp.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 992c9dc3..d5de063d 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -565,7 +565,28 @@ class SFTPTest (unittest.TestCase):
f = open(localname, 'r')
self.assertEquals(text, f.read(128))
f.close()
-
+
os.unlink(localname)
sftp.unlink(FOLDER + '/bunny.txt')
+
+ def test_K_check(self):
+ """
+ verify that file.check() works against our own server.
+ (it's an sftp extension that we support, and may be the only ones who
+ support it.)
+ """
+ f = sftp.open(FOLDER + '/kitty.txt', 'w')
+ f.write('here kitty kitty' * 64)
+ f.close()
+ try:
+ f = sftp.open(FOLDER + '/kitty.txt', 'r')
+ sum = f.check('sha1')
+ self.assertEquals('91059CFC6615941378D413CB5ADAF4C5EB293402', paramiko.util.hexify(sum))
+ sum = f.check('md5', 0, 512)
+ self.assertEquals('93DE4788FCA28D471516963A1FE3856A', paramiko.util.hexify(sum))
+ sum = f.check('md5', 0, 0, 510)
+ self.assertEquals('EB3B45B8CD55A0707D99B177544A319F373183D241432BB2157AB9E46358C4AC90370B5CADE5D90336FC1716F90B36D6',
+ paramiko.util.hexify(sum))
+ finally:
+ sftp.unlink(FOLDER + '/kitty.txt')