diff options
author | Scott Maxwell <scott@codecobblers.com> | 2013-11-01 00:37:11 -0700 |
---|---|---|
committer | Scott Maxwell <scott@codecobblers.com> | 2013-11-01 00:37:11 -0700 |
commit | 8a7267beeb3435fa16c06d22c201650e1e593d89 (patch) | |
tree | 0f78c4a7d45f226abcb60cd53907d6be3ecd0656 /tests | |
parent | d5ce2b43d602282fe2aa826481759c48d18c9b38 (diff) |
Eliminate all uses of b'' syntax to allow for Python 2.5 support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_message.py | 15 | ||||
-rw-r--r-- | tests/test_packetizer.py | 21 | ||||
-rw-r--r-- | tests/test_pkey.py | 7 | ||||
-rw-r--r-- | tests/test_transport.py | 2 |
4 files changed, 13 insertions, 32 deletions
diff --git a/tests/test_message.py b/tests/test_message.py index 2580115e..dde694f7 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -21,22 +21,17 @@ Some unit tests for ssh protocol message blocks. """ import unittest +from binascii import unhexlify from paramiko.message import Message from paramiko.common import * class MessageTest (unittest.TestCase): - if PY3: - __a = b'\x00\x00\x00\x17\x07\x60\xe0\x90\x00\x00\x00\x01q\x00\x00\x00\x05hello\x00\x00\x03\xe8' + (b'x' * 1000) - __b = b'\x01\x00\xf3\x00\x3f\x00\x00\x00\x10huey,dewey,louie' - __c = b'\x00\x00\x00\x05\xff\x00\x00\x00\x07\x00\xf5\xe4\xd3\xc2\xb1\x09\x00\x00\x00\x01\x11\x00\x00\x00\x07\x00\xf5\xe4\xd3\xc2\xb1\x09\x00\x00\x00\x06\x9a\x1b\x2c\x3d\x4e\xf7' - __d = b'\x00\x00\x00\x05\xff\x00\x00\x00\x05\x11\x22\x33\x44\x55\xff\x00\x00\x00\x0a\x00\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03cat\x00\x00\x00\x03a,b' - else: - __a = '\x00\x00\x00\x17\x07\x60\xe0\x90\x00\x00\x00\x01q\x00\x00\x00\x05hello\x00\x00\x03\xe8' + ('x' * 1000) - __b = '\x01\x00\xf3\x00\x3f\x00\x00\x00\x10huey,dewey,louie' - __c = '\x00\x00\x00\x05\xff\x00\x00\x00\x07\x00\xf5\xe4\xd3\xc2\xb1\x09\x00\x00\x00\x01\x11\x00\x00\x00\x07\x00\xf5\xe4\xd3\xc2\xb1\x09\x00\x00\x00\x06\x9a\x1b\x2c\x3d\x4e\xf7' - __d = '\x00\x00\x00\x05\xff\x00\x00\x00\x05\x11\x22\x33\x44\x55\xff\x00\x00\x00\x0a\x00\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03cat\x00\x00\x00\x03a,b' + __a = unhexlify('000000170760e09000000001710000000568656c6c6f000003e8') + (b('x') * 1000) + __b = unhexlify('0100f3003f00000010687565792c64657765792c6c6f756965') + __c = unhexlify('00000005ff0000000700f5e4d3c2b10900000001110000000700f5e4d3c2b109000000069a1b2c3d4ef7') + __d = unhexlify('00000005ff000000051122334455ff0000000a00f00000000000000000010000000363617400000003612c62') def test_1_encode(self): msg = Message() diff --git a/tests/test_packetizer.py b/tests/test_packetizer.py index 111ecb96..b0e8fd42 100644 --- a/tests/test_packetizer.py +++ b/tests/test_packetizer.py @@ -21,18 +21,15 @@ Some unit tests for the ssh2 protocol in Transport. """ import unittest +from binascii import unhexlify from tests.loop import LoopSocket from Crypto.Cipher import AES from Crypto.Hash import SHA, HMAC from paramiko import Message, Packetizer, util from paramiko.common import * -if PY3: - x55 = b'\x55' - x1f = b'\x1f' -else: - x55 = '\x55' - x1f = '\x1f' +x55 = byte_chr(0x55) +x1f = byte_chr(0x1f) class PacketizerTest (unittest.TestCase): @@ -58,10 +55,7 @@ class PacketizerTest (unittest.TestCase): data = rsock.recv(100) # 32 + 12 bytes of MAC = 44 self.assertEquals(44, len(data)) - if PY3: - self.assertEquals(b'\x43\x91\x97\xbd\x5b\x50\xac\x25\x87\xc2\xc4\x6b\xc7\xe9\x38\xc0', data[:16]) - else: - self.assertEquals('\x43\x91\x97\xbd\x5b\x50\xac\x25\x87\xc2\xc4\x6b\xc7\xe9\x38\xc0', data[:16]) + self.assertEquals(unhexlify('439197bd5b50ac2587c2c46bc7e938c0'), data[:16]) def test_2_read (self): rsock = LoopSocket() @@ -72,12 +66,7 @@ class PacketizerTest (unittest.TestCase): p.set_hexdump(True) cipher = AES.new(zero_byte * 16, AES.MODE_CBC, x55 * 16) p.set_inbound_cipher(cipher, 16, SHA, 12, x1f * 20) - if PY3: - wsock.send(b'C\x91\x97\xbd[P\xac%\x87\xc2\xc4k\xc7\xe98\xc0' + \ - b'\x90\xd2\x16V\rqsa8|L=\xfb\x97}\xe2n\x03\xb1\xa0\xc2\x1c\xd6AAL\xb4Y') - else: - wsock.send('C\x91\x97\xbd[P\xac%\x87\xc2\xc4k\xc7\xe98\xc0' + \ - '\x90\xd2\x16V\rqsa8|L=\xfb\x97}\xe2n\x03\xb1\xa0\xc2\x1c\xd6AAL\xb4Y') + wsock.send(unhexlify('439197bd5b50ac2587c2c46bc7e938c090d216560d717361387c4c3dfb977de26e03b1a0c21cd641414cb459')) cmd, m = p.read_message() self.assertEquals(100, cmd) self.assertEquals(100, m.get_int()) diff --git a/tests/test_pkey.py b/tests/test_pkey.py index b75f9a1e..00001600 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -23,7 +23,7 @@ Some unit tests for public/private key objects. from binascii import hexlify, unhexlify import unittest from paramiko import RSAKey, DSSKey, ECDSAKey, Message, util -from paramiko.common import rng, StringIO, byte_chr, b, PY3 +from paramiko.common import rng, StringIO, byte_chr, b, PY3, bytes from tests.util import test_path # from openssh's ssh-keygen @@ -77,10 +77,7 @@ ADRvOqQ5R98Sxst765CAqXmRtz8vwoD96g== -----END EC PRIVATE KEY----- """ -if PY3: - x1234 = b'\x01\x02\x03\x04' -else: - x1234 = '\x01\x02\x03\x04' +x1234 = unhexlify('01020304') class KeyTest (unittest.TestCase): diff --git a/tests/test_transport.py b/tests/test_transport.py index 230f4a28..f60c2949 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -33,7 +33,7 @@ from paramiko import Transport, SecurityOptions, ServerInterface, RSAKey, DSSKey SSHException, BadAuthenticationType, InteractiveQuery, ChannelException from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED -from paramiko.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST, b +from paramiko.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST, b, bytes from paramiko.message import Message from tests.loop import LoopSocket from tests.util import ParamikoTest, test_path |