aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_console_contentview.py16
-rw-r--r--test/test_dump.py4
-rw-r--r--test/test_flow.py4
-rw-r--r--test/test_platform_pf.py2
-rw-r--r--test/test_server.py3
-rw-r--r--test/tservers.py5
-rw-r--r--test/tutils.py2
7 files changed, 20 insertions, 16 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index 1798ce85..f6b45f67 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -114,16 +114,16 @@ class TestContentView:
def test_view_image(self):
v = cv.ViewImage()
p = tutils.test_data.path("data/image.png")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
p = tutils.test_data.path("data/image.gif")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
p = tutils.test_data.path("data/image-err1.jpg")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
p = tutils.test_data.path("data/image.ico")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
assert not v([], "flibble", sys.maxint)
@@ -224,22 +224,22 @@ if pyamf:
v = cv.ViewAMF()
p = tutils.test_data.path("data/amf01")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
p = tutils.test_data.path("data/amf02")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
def test_view_amf_response():
v = cv.ViewAMF()
p = tutils.test_data.path("data/amf03")
- assert v([], file(p).read(), sys.maxint)
+ assert v([], file(p,"rb").read(), sys.maxint)
if cv.ViewProtobuf.is_available():
def test_view_protobuf_request():
v = cv.ViewProtobuf()
p = tutils.test_data.path("data/protobuf01")
- content_type, output = v([], file(p).read(), sys.maxint)
+ content_type, output = v([], file(p,"rb").read(), sys.maxint)
assert content_type == "Protobuf"
assert output[0].text == '1: "3bbc333c-e61c-433b-819a-0b9a8cc103b8"'
diff --git a/test/test_dump.py b/test/test_dump.py
index 94d0b195..6a35cdec 100644
--- a/test/test_dump.py
+++ b/test/test_dump.py
@@ -46,7 +46,7 @@ class TestDumpMaster:
return cs.getvalue()
def _flowfile(self, path):
- f = open(path, "w")
+ f = open(path, "wb")
fw = flow.FlowWriter(f)
t = tutils.tflow_full()
t.response = tutils.tresp(t.request)
@@ -128,7 +128,7 @@ class TestDumpMaster:
with tutils.tmpdir() as d:
p = os.path.join(d, "a")
self._dummy_cycle(1, None, "", wfile=p, verbosity=0)
- assert len(list(flow.FlowReader(open(p)).stream())) == 1
+ assert len(list(flow.FlowReader(open(p,"rb")).stream())) == 1
def test_write_err(self):
tutils.raises(
diff --git a/test/test_flow.py b/test/test_flow.py
index 4ad692bc..977cdd4e 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -733,7 +733,7 @@ class TestFlowMaster:
with tutils.tmpdir() as tdir:
p = os.path.join(tdir, "foo")
def r():
- r = flow.FlowReader(open(p))
+ r = flow.FlowReader(open(p,"rb"))
return list(r.stream())
s = flow.State()
@@ -1191,6 +1191,8 @@ class TestClientConnect:
c3 = c.copy()
assert c3 == c
+ assert str(c)
+
def test_decoded():
r = tutils.treq()
diff --git a/test/test_platform_pf.py b/test/test_platform_pf.py
index a2e7c3c1..f048fdcc 100644
--- a/test/test_platform_pf.py
+++ b/test/test_platform_pf.py
@@ -5,7 +5,7 @@ from libmproxy.platform import pf
class TestLookup:
def test_simple(self):
p = tutils.test_data.path("data/pf01")
- d = open(p).read()
+ d = open(p,"rb").read()
assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
assert not pf.lookup("192.168.1.112", 40000, d)
assert not pf.lookup("192.168.1.111", 40001, d)
diff --git a/test/test_server.py b/test/test_server.py
index 6a88578c..079ed8ce 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -1,7 +1,7 @@
import socket, time
import mock
from netlib import tcp, http_auth, http
-from libpathod import pathoc
+from libpathod import pathoc, pathod
import tutils, tservers
from libmproxy import flow, proxy
@@ -173,6 +173,7 @@ class TestHTTPConnectSSLError(tservers.HTTPProxTest):
class TestHTTPS(tservers.HTTPProxTest, CommonMixin):
ssl = True
+ ssloptions = pathod.SSLOptions(request_client_cert=True)
clientcerts = True
def test_clientcert(self):
f = self.pathod("304")
diff --git a/test/tservers.py b/test/tservers.py
index 91ce4dc0..1197fb69 100644
--- a/test/tservers.py
+++ b/test/tservers.py
@@ -69,6 +69,7 @@ class ProxyThread(threading.Thread):
class ProxTestBase:
# Test Configuration
ssl = None
+ ssloptions = False
clientcerts = False
certfile = None
no_upstream_cert = False
@@ -77,8 +78,8 @@ class ProxTestBase:
@classmethod
def setupAll(cls):
cls.tqueue = Queue.Queue()
- cls.server = libpathod.test.Daemon(ssl=cls.ssl)
- cls.server2 = libpathod.test.Daemon(ssl=cls.ssl)
+ cls.server = libpathod.test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions)
+ cls.server2 = libpathod.test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions)
pconf = cls.get_proxy_config()
config = proxy.ProxyConfig(
no_upstream_cert = cls.no_upstream_cert,
diff --git a/test/tutils.py b/test/tutils.py
index 1a1c8724..fbce615a 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -20,7 +20,7 @@ def tresp(req=None):
req = treq()
headers = flow.ODictCaseless()
headers["header_response"] = ["svalue"]
- cert = certutils.SSLCert.from_der(file(test_data.path("data/dercert")).read())
+ cert = certutils.SSLCert.from_der(file(test_data.path("data/dercert"),"rb").read())
resp = flow.Response(req, (1, 1), 200, "message", headers, "content_response", cert)
resp.reply = controller.DummyReply()
return resp