aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_socks.py7
-rw-r--r--test/test_utils.py18
2 files changed, 6 insertions, 19 deletions
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