From e69133f98c513a99c017ad561ea9195280e3f7c5 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 25 Jun 2014 21:16:47 +0200 Subject: remove ntop windows workaround --- test/test_socks.py | 7 ++++++- test/test_utils.py | 18 ------------------ 2 files changed, 6 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/test_socks.py b/test/test_socks.py index 3771df62..4787e309 100644 --- a/test/test_socks.py +++ b/test/test_socks.py @@ -1,5 +1,6 @@ from cStringIO import StringIO import socket +from nose.plugins.skip import SkipTest from netlib import socks, utils import tutils @@ -47,9 +48,13 @@ def test_message(): assert raw.read(2) == "\xBE\xEF" assert msg.addr == ("127.0.0.1", 0xDEAD) + +def test_message_ipv6(): + if not hasattr(socket, "inet_ntop"): + raise SkipTest("Skipped because inet_ntop is not available") # Test ATYP=0x04 (IPV6) ipv6_addr = "2001:0db8:85a3:08d3:1319:8a2e:0370:7344" - raw = StringIO("\x05\x01\x00\x04" + utils.inet_pton(socket.AF_INET6, ipv6_addr) + "\xDE\xAD\xBE\xEF") + raw = StringIO("\x05\x01\x00\x04" + socket.inet_pton(socket.AF_INET6, ipv6_addr) + "\xDE\xAD\xBE\xEF") msg = socks.Message.from_file(raw) assert raw.read(2) == "\xBE\xEF" assert msg.addr.host == ipv6_addr \ No newline at end of file diff --git a/test/test_utils.py b/test/test_utils.py index a9a48cd0..971e5076 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -10,21 +10,3 @@ def test_cleanBin(): assert utils.cleanBin("\00ne") == ".ne" assert utils.cleanBin("\nne") == "\nne" assert utils.cleanBin("\nne", True) == ".ne" - -def test_ntop_pton(): - for family, ip_string, packed_ip in ( - (socket.AF_INET, - "127.0.0.1", - "\x7f\x00\x00\x01"), - (socket.AF_INET6, - "2001:0db8:85a3:08d3:1319:8a2e:0370:7344", - " \x01\r\xb8\x85\xa3\x08\xd3\x13\x19\x8a.\x03psD")): - assert ip_string == utils.inet_ntop(family, packed_ip) - assert packed_ip == utils.inet_pton(family, ip_string) - if hasattr(socket, "inet_ntop"): - ntop, pton = socket.inet_ntop, socket.inet_pton - delattr(socket,"inet_ntop") - delattr(socket,"inet_pton") - assert ip_string == utils.inet_ntop(family, packed_ip) - assert packed_ip == utils.inet_pton(family, ip_string) - socket.inet_ntop, socket.inet_pton = ntop, pton \ No newline at end of file -- cgit v1.2.3