diff options
author | Sebastian Deiss <s.deiss@science-computing.de> | 2014-03-26 11:39:26 +0100 |
---|---|---|
committer | Sebastian Deiss <s.deiss@science-computing.de> | 2014-03-26 11:39:26 +0100 |
commit | a23d9bc654b5278f1ab43df825ed559e4f9a2332 (patch) | |
tree | 593ae35cd2b7f550f5b9ff3d4babac57f072e741 /tests | |
parent | 5407b1a27468d5abedde93b51aad5bd97bd046c4 (diff) | |
parent | bd8f96d33a3e1ee6162540a6f230ef93e435528a (diff) |
Merge branch 'master' into gssapi-py3-support
Conflicts:
.gitignore
README
demos/demo_simple.py
dev-requirements.txt
paramiko/__init__.py
paramiko/_winapi.py
paramiko/agent.py
paramiko/auth_handler.py
paramiko/ber.py
paramiko/buffered_pipe.py
paramiko/channel.py
paramiko/client.py
paramiko/common.py
paramiko/dsskey.py
paramiko/ecdsakey.py
paramiko/file.py
paramiko/hostkeys.py
paramiko/kex_gex.py
paramiko/kex_group1.py
paramiko/message.py
paramiko/packet.py
paramiko/pkey.py
paramiko/primes.py
paramiko/proxy.py
paramiko/py3compat.py
paramiko/server.py
paramiko/sftp_client.py
paramiko/transport.py
paramiko/util.py
paramiko/win_pageant.py
setup.py
sites/shared_conf.py
sites/www/changelog.rst
sites/www/conf.py
sites/www/index.rst
sites/www/installing.rst
test.py
tests/loop.py
tests/stub_sftp.py
tests/test_auth.py
tests/test_client.py
tests/test_file.py
tests/test_hostkeys.py
tests/test_kex.py
tests/test_message.py
tests/test_packetizer.py
tests/test_pkey.py
tests/test_sftp.py
tests/test_sftp_big.py
tests/test_transport.py
tests/test_util.py
Diffstat (limited to 'tests')
-rw-r--r-- | tests/loop.py | 2 | ||||
-rw-r--r-- | tests/stub_sftp.py | 6 | ||||
-rw-r--r-- | tests/test_auth.py | 3 | ||||
-rw-r--r-- | tests/test_buffered_pipe.py | 14 | ||||
-rw-r--r-- | tests/test_client.py | 7 | ||||
-rwxr-xr-x | tests/test_file.py | 2 | ||||
-rw-r--r-- | tests/test_hostkeys.py | 3 | ||||
-rw-r--r-- | tests/test_kex.py | 12 | ||||
-rw-r--r-- | tests/test_message.py | 2 | ||||
-rw-r--r-- | tests/test_packetizer.py | 8 | ||||
-rw-r--r-- | tests/test_pkey.py | 3 | ||||
-rwxr-xr-x | tests/test_sftp.py | 6 | ||||
-rw-r--r-- | tests/test_sftp_big.py | 7 | ||||
-rw-r--r-- | tests/test_transport.py | 9 | ||||
-rw-r--r-- | tests/test_util.py | 5 |
15 files changed, 49 insertions, 40 deletions
diff --git a/tests/loop.py b/tests/loop.py index 6e933f83..4f5dc163 100644 --- a/tests/loop.py +++ b/tests/loop.py @@ -21,7 +21,7 @@ """ import threading, socket -from paramiko.common import * +from paramiko.common import asbytes class LoopSocket (object): diff --git a/tests/stub_sftp.py b/tests/stub_sftp.py index 58e4be26..24380ba1 100644 --- a/tests/stub_sftp.py +++ b/tests/stub_sftp.py @@ -24,7 +24,7 @@ import os import sys from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \ SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED -from paramiko.common import * +from paramiko.common import o666 class StubServer (ServerInterface): @@ -64,7 +64,7 @@ class StubSFTPServer (SFTPServerInterface): def list_folder(self, path): path = self._realpath(path) try: - out = [ ] + out = [] flist = os.listdir(path) for fname in flist: attr = SFTPAttributes.from_stat(os.stat(os.path.join(path, fname))) @@ -91,7 +91,7 @@ class StubSFTPServer (SFTPServerInterface): def open(self, path, flags, attr): path = self._realpath(path) try: - binary_flag = getattr(os, 'O_BINARY', 0) + binary_flag = getattr(os, 'O_BINARY', 0) flags |= binary_flag mode = getattr(attr, 'st_mode', None) if mode is not None: diff --git a/tests/test_auth.py b/tests/test_auth.py index d26b1807..1d972d53 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -25,10 +25,9 @@ import threading import unittest from paramiko import Transport, ServerInterface, RSAKey, DSSKey, \ - SSHException, BadAuthenticationType, InteractiveQuery, ChannelException, \ + BadAuthenticationType, InteractiveQuery, \ AuthenticationException from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL -from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED from paramiko.py3compat import u from tests.loop import LoopSocket from tests.util import test_path diff --git a/tests/test_buffered_pipe.py b/tests/test_buffered_pipe.py index b9d2bef4..b66edff9 100644 --- a/tests/test_buffered_pipe.py +++ b/tests/test_buffered_pipe.py @@ -22,7 +22,6 @@ Some unit tests for BufferedPipe. import threading import time -import unittest from paramiko.buffered_pipe import BufferedPipe, PipeTimeout from paramiko import pipe from paramiko.py3compat import b @@ -30,16 +29,16 @@ from paramiko.py3compat import b from tests.util import ParamikoTest -def delay_thread(pipe): - pipe.feed('a') +def delay_thread(p): + p.feed('a') time.sleep(0.5) - pipe.feed('b') - pipe.close() + p.feed('b') + p.close() -def close_thread(pipe): +def close_thread(p): time.sleep(0.2) - pipe.close() + p.close() class BufferedPipeTest(ParamikoTest): @@ -91,4 +90,3 @@ class BufferedPipeTest(ParamikoTest): self.assertTrue(p._set) p2.clear() self.assertFalse(p._set) - diff --git a/tests/test_client.py b/tests/test_client.py index 97150979..7e5c80b4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -29,6 +29,7 @@ import warnings import os from tests.util import test_path import paramiko +from paramiko.common import PY2 class NullServer (paramiko.ServerInterface): @@ -157,7 +158,7 @@ class SSHClientTest (unittest.TestCase): self.tc = paramiko.SSHClient() self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key) - self.tc.connect(self.addr, self.port, username='slowdive', key_filename=[ test_path('test_rsa.key'), test_path('test_dss.key') ]) + self.tc.connect(self.addr, self.port, username='slowdive', key_filename=[test_path('test_rsa.key'), test_path('test_dss.key')]) self.event.wait(1.0) self.assertTrue(self.event.isSet()) @@ -218,6 +219,10 @@ class SSHClientTest (unittest.TestCase): verify that when an SSHClient is collected, its transport (and the transport's packetizer) is closed. """ + # Unclear why this is borked on Py3, but it is, and does not seem worth + # pursuing at the moment. + if not PY2: + return threading.Thread(target=self._run).start() host_key = paramiko.RSAKey.from_private_key_file(test_path('test_rsa.key')) public_host_key = paramiko.RSAKey(data=host_key.asbytes()) diff --git a/tests/test_file.py b/tests/test_file.py index 33a49130..e11d7fd5 100755 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -22,7 +22,7 @@ Some unit tests for the BufferedFile abstraction. import unittest from paramiko.file import BufferedFile -from paramiko.common import * +from paramiko.common import linefeed_byte, crlf, cr_byte class LoopbackFile (BufferedFile): diff --git a/tests/test_hostkeys.py b/tests/test_hostkeys.py index 9a7e3689..0ee1bbf0 100644 --- a/tests/test_hostkeys.py +++ b/tests/test_hostkeys.py @@ -20,12 +20,11 @@ Some unit tests for HostKeys. """ -import base64 from binascii import hexlify import os import unittest import paramiko -from paramiko.py3compat import b, decodebytes +from paramiko.py3compat import decodebytes test_hosts_file = """\ diff --git a/tests/test_kex.py b/tests/test_kex.py index e69c051b..c522be46 100644 --- a/tests/test_kex.py +++ b/tests/test_kex.py @@ -26,7 +26,7 @@ import paramiko.util from paramiko.kex_group1 import KexGroup1 from paramiko.kex_gex import KexGex from paramiko import Message -from paramiko.common import * +from paramiko.common import byte_chr class FakeRng (object): @@ -37,8 +37,10 @@ class FakeRng (object): class FakeKey (object): def __str__(self): return 'fake-key' + def asbytes(self): return b'fake-key' + def sign_ssh_data(self, rng, H): return b'fake-sig' @@ -46,6 +48,7 @@ class FakeKey (object): class FakeModulusPack (object): P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF G = 2 + def get_modulus(self, min, ask, max): return self.G, self.P @@ -59,19 +62,26 @@ class FakeTransport (object): def _send_message(self, m): self._message = m + def _expect_packet(self, *t): self._expect = t + def _set_K_H(self, K, H): self._K = K self._H = H + def _verify_key(self, host_key, sig): self._verify = (host_key, sig) + def _activate_outbound(self): self._activated = True + def _log(self, level, s): pass + def get_server_key(self): return FakeKey() + def _get_modulus_pack(self): return FakeModulusPack() diff --git a/tests/test_message.py b/tests/test_message.py index 4da52cfb..f308c037 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -22,7 +22,7 @@ Some unit tests for ssh protocol message blocks. import unittest from paramiko.message import Message -from paramiko.common import * +from paramiko.common import byte_chr, zero_byte class MessageTest (unittest.TestCase): diff --git a/tests/test_packetizer.py b/tests/test_packetizer.py index 5c36fed6..d4d5544e 100644 --- a/tests/test_packetizer.py +++ b/tests/test_packetizer.py @@ -23,9 +23,9 @@ Some unit tests for the ssh2 protocol in Transport. import unittest from tests.loop import LoopSocket from Crypto.Cipher import AES -from Crypto.Hash import SHA, HMAC +from Crypto.Hash import SHA from paramiko import Message, Packetizer, util -from paramiko.common import * +from paramiko.common import byte_chr, zero_byte x55 = byte_chr(0x55) x1f = byte_chr(0x1f) @@ -33,7 +33,7 @@ x1f = byte_chr(0x1f) class PacketizerTest (unittest.TestCase): - def test_1_write (self): + def test_1_write(self): rsock = LoopSocket() wsock = LoopSocket() rsock.link(wsock) @@ -56,7 +56,7 @@ class PacketizerTest (unittest.TestCase): self.assertEqual(44, len(data)) self.assertEqual(b'\x43\x91\x97\xbd\x5b\x50\xac\x25\x87\xc2\xc4\x6b\xc7\xe9\x38\xc0', data[:16]) - def test_2_read (self): + def test_2_read(self): rsock = LoopSocket() wsock = LoopSocket() rsock.link(wsock) diff --git a/tests/test_pkey.py b/tests/test_pkey.py index 2e565a5f..6ff68fc2 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 import unittest from paramiko import RSAKey, DSSKey, ECDSAKey, Message, util -from paramiko.common import rng, StringIO, byte_chr, b, bytes +from paramiko.py3compat import StringIO, byte_chr, b, bytes +from paramiko.common import rng from tests.util import test_path # from openssh's ssh-keygen diff --git a/tests/test_sftp.py b/tests/test_sftp.py index f8fab1ce..6417ac90 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -25,13 +25,15 @@ do test file operations in (so no existing files will be harmed). from binascii import hexlify import os +import sys import warnings import threading import unittest from tempfile import mkstemp import paramiko -from paramiko.common import * +from paramiko.py3compat import PY2, b, u, StringIO +from paramiko.common import o777, o600, o666, o644 from tests.stub_sftp import StubServer, StubSFTPServer from tests.loop import LoopSocket from tests.util import test_path @@ -553,6 +555,7 @@ class SFTPTest (unittest.TestCase): with open(localname, 'wb') as f: f.write(text) saved_progress = [] + def progress_callback(x, y): saved_progress.append((x, y)) sftp.put(localname, FOLDER + '/bunny.txt', progress_callback) @@ -662,6 +665,7 @@ class SFTPTest (unittest.TestCase): with open(localname, 'w') as f: f.write(text) saved_progress = [] + def progress_callback(x, y): saved_progress.append((x, y)) res = sftp.put(localname, FOLDER + '/bunny.txt', progress_callback, False) diff --git a/tests/test_sftp_big.py b/tests/test_sftp_big.py index 6870c6b4..521fbdc8 100644 --- a/tests/test_sftp_big.py +++ b/tests/test_sftp_big.py @@ -23,19 +23,14 @@ a real actual sftp server is contacted, and a new folder is created there to do test file operations in (so no existing files will be harmed). """ -import logging import os import random import struct import sys -import threading import time import unittest -import paramiko -from paramiko.common import * -from tests.stub_sftp import StubServer, StubSFTPServer -from tests.loop import LoopSocket +from paramiko.common import o660 from tests.test_sftp import get_sftp FOLDER = os.environ.get('TEST_FOLDER', 'temp-testing000') diff --git a/tests/test_transport.py b/tests/test_transport.py index 876759c8..485a18e8 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -23,17 +23,16 @@ Some unit tests for the ssh2 protocol in Transport. from binascii import hexlify import select import socket -import sys import time import threading -import unittest import random from paramiko import Transport, SecurityOptions, ServerInterface, RSAKey, DSSKey, \ - SSHException, BadAuthenticationType, InteractiveQuery, ChannelException -from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL + SSHException, ChannelException +from paramiko import AUTH_FAILED, AUTH_SUCCESSFUL from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED -from paramiko.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST, b, bytes +from paramiko.common import MSG_KEXINIT, cMSG_CHANNEL_WINDOW_ADJUST +from paramiko.py3compat import bytes from paramiko.message import Message from tests.loop import LoopSocket from tests.util import ParamikoTest, test_path diff --git a/tests/test_util.py b/tests/test_util.py index 4f85c391..6bde4045 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -23,11 +23,10 @@ Some unit tests for utility functions. from binascii import hexlify import errno import os -import unittest from Crypto.Hash import SHA import paramiko.util from paramiko.util import lookup_ssh_host_config as host_config -from paramiko.py3compat import StringIO, byte_ord, b +from paramiko.py3compat import StringIO, byte_ord from tests.util import ParamikoTest @@ -338,4 +337,4 @@ AddressFamily inet IdentityFile something_%l_using_fqdn """ config = paramiko.util.parse_ssh_config(StringIO(test_config)) - assert config.lookup('meh') # will die during lookup() if bug regresses + assert config.lookup('meh') # will die during lookup() if bug regresses |