summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_kex.py10
-rw-r--r--tests/test_pkey.py11
-rwxr-xr-xtests/test_sftp.py28
-rw-r--r--tests/test_util.py4
4 files changed, 40 insertions, 13 deletions
diff --git a/tests/test_kex.py b/tests/test_kex.py
index 2ecb757..f6e6996 100644
--- a/tests/test_kex.py
+++ b/tests/test_kex.py
@@ -28,17 +28,15 @@ from paramiko.kex_gex import KexGex
from paramiko import Message
-class FakeRandpool (object):
- def stir(self):
- pass
- def get_bytes(self, n):
+class FakeRng (object):
+ def read(self, n):
return chr(0xcc) * n
class FakeKey (object):
def __str__(self):
return 'fake-key'
- def sign_ssh_data(self, randpool, H):
+ def sign_ssh_data(self, rng, H):
return 'fake-sig'
@@ -50,7 +48,7 @@ class FakeModulusPack (object):
class FakeTransport (object):
- randpool = FakeRandpool()
+ rng = FakeRng()
local_version = 'SSH-2.0-paramiko_1.0'
remote_version = 'SSH-2.0-lame'
local_kex_init = 'local-kex-init'
diff --git a/tests/test_pkey.py b/tests/test_pkey.py
index e40bee1..89d5580 100644
--- a/tests/test_pkey.py
+++ b/tests/test_pkey.py
@@ -23,7 +23,8 @@ Some unit tests for public/private key objects.
from binascii import hexlify, unhexlify
import StringIO
import unittest
-from paramiko import RSAKey, DSSKey, Message, util, randpool
+from paramiko import RSAKey, DSSKey, Message, util
+from paramiko.common import rng
# from openssh's ssh-keygen
PUB_RSA = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA049W6geFpmsljTwfvI1UmKWWJPNFI74+vNKTk4dmzkQY2yAMs6FhlvhlI8ysU4oj71ZsRYMecHbBbxdN79+JRFVYTKaLqjwGENeTd+yv4q+V2PvZv3fLnzApI3l7EJCqhWwJUHJ1jAkZzqDx0tyOL4uoZpww3nmE0kb3y21tH4c='
@@ -151,7 +152,7 @@ class KeyTest (unittest.TestCase):
def test_8_sign_rsa(self):
# verify that the rsa private key can sign and verify
key = RSAKey.from_private_key_file('tests/test_rsa.key')
- msg = key.sign_ssh_data(randpool, 'ice weasels')
+ msg = key.sign_ssh_data(rng, 'ice weasels')
self.assert_(type(msg) is Message)
msg.rewind()
self.assertEquals('ssh-rsa', msg.get_string())
@@ -164,7 +165,7 @@ class KeyTest (unittest.TestCase):
def test_9_sign_dss(self):
# verify that the dss private key can sign and verify
key = DSSKey.from_private_key_file('tests/test_dss.key')
- msg = key.sign_ssh_data(randpool, 'ice weasels')
+ msg = key.sign_ssh_data(rng, 'ice weasels')
self.assert_(type(msg) is Message)
msg.rewind()
self.assertEquals('ssh-dss', msg.get_string())
@@ -178,12 +179,12 @@ class KeyTest (unittest.TestCase):
def test_A_generate_rsa(self):
key = RSAKey.generate(1024)
- msg = key.sign_ssh_data(randpool, 'jerri blank')
+ msg = key.sign_ssh_data(rng, 'jerri blank')
msg.rewind()
self.assert_(key.verify_ssh_sig('jerri blank', msg))
def test_B_generate_dss(self):
key = DSSKey.generate(1024)
- msg = key.sign_ssh_data(randpool, 'jerri blank')
+ msg = key.sign_ssh_data(rng, 'jerri blank')
msg.rewind()
self.assert_(key.verify_ssh_sig('jerri blank', msg))
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index f9d7270..2eadabc 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -36,6 +36,7 @@ import unittest
import paramiko
from stub_sftp import StubServer, StubSFTPServer
from loop import LoopSocket
+from paramiko.sftp_attr import SFTPAttributes
ARTICLE = '''
Insulin sensitivity and liver insulin receptor structure in ducks from two
@@ -667,6 +668,33 @@ class SFTPTest (unittest.TestCase):
finally:
sftp.unlink(FOLDER + '/zero')
+ def test_N_put_without_confirm(self):
+ """
+ verify that get/put work without confirmation.
+ """
+ import os, warnings
+ warnings.filterwarnings('ignore', 'tempnam.*')
+
+ localname = os.tempnam()
+ text = 'All I wanted was a plastic bunny rabbit.\n'
+ f = open(localname, 'wb')
+ f.write(text)
+ f.close()
+ saved_progress = []
+ def progress_callback(x, y):
+ saved_progress.append((x, y))
+ res = sftp.put(localname, FOLDER + '/bunny.txt', progress_callback, False)
+
+ self.assertEquals(SFTPAttributes().attr, res.attr)
+
+ f = sftp.open(FOLDER + '/bunny.txt', 'r')
+ self.assertEquals(text, f.read(128))
+ f.close()
+ self.assertEquals((41, 41), saved_progress[-1])
+
+ os.unlink(localname)
+ sftp.unlink(FOLDER + '/bunny.txt')
+
def XXX_test_M_seek_append(self):
"""
verify that seek does't affect writes during append.
diff --git a/tests/test_util.py b/tests/test_util.py
index 3569abf..256c3d7 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -147,8 +147,8 @@ class UtilTest (unittest.TestCase):
os.unlink('hostfile.temp')
def test_6_random(self):
- from paramiko.common import randpool
+ from paramiko.common import rng
# just verify that we can pull out 32 bytes and not get an exception.
- x = randpool.get_bytes(32)
+ x = rng.read(32)
self.assertEquals(len(x), 32)