diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-11-11 12:29:34 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-11-11 12:29:34 +0100 |
commit | 8635e00175117d8574b4bea5edc1c43528ddf3e9 (patch) | |
tree | 1be23a6349a8fb81a89f8417b0b9d236d1829639 /test/test_pathod.py | |
parent | b917b61e6aead4f353ef15838315ecc0df721e29 (diff) | |
parent | 27c7e9e9345bbc458e7efc4093c2074e19011d12 (diff) | |
download | mitmproxy-8635e00175117d8574b4bea5edc1c43528ddf3e9.tar.gz mitmproxy-8635e00175117d8574b4bea5edc1c43528ddf3e9.tar.bz2 mitmproxy-8635e00175117d8574b4bea5edc1c43528ddf3e9.zip |
Merge remote-tracking branch 'origin/master'
Conflicts:
setup.py
Diffstat (limited to 'test/test_pathod.py')
-rw-r--r-- | test/test_pathod.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/test/test_pathod.py b/test/test_pathod.py index a98ce2de..8b37b545 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -1,19 +1,9 @@ -import pprint from libpathod import pathod, version -from netlib import tcp, http, certutils -import requests +from netlib import tcp, http import tutils -class TestPathod: - def test_instantiation(self): - p = pathod.Pathod( - ("127.0.0.1", 0), - anchors = [(".*", "200:da")] - ) - assert p.anchors - tutils.raises("invalid regex", pathod.Pathod, ("127.0.0.1", 0), anchors=[("*", "200:da")]) - tutils.raises("invalid page spec", pathod.Pathod, ("127.0.0.1", 0), anchors=[("foo", "bar")]) +class TestPathod: def test_logging(self): p = pathod.Pathod(("127.0.0.1", 0)) assert len(p.get_log()) == 0 @@ -30,6 +20,7 @@ class TestPathod: class TestNoWeb(tutils.DaemonTests): noweb = True + def test_noweb(self): assert self.get("200:da").status_code == 200 assert self.getpath("/").status_code == 800 @@ -37,6 +28,7 @@ class TestNoWeb(tutils.DaemonTests): class TestTimeout(tutils.DaemonTests): timeout = 0.01 + def test_noweb(self): # FIXME: Add float values to spec language, reduce test timeout to # increase test performance @@ -46,6 +38,7 @@ class TestTimeout(tutils.DaemonTests): class TestNoApi(tutils.DaemonTests): noapi = True + def test_noapi(self): assert self.getpath("/log").status_code == 404 r = self.getpath("/") @@ -59,7 +52,10 @@ class TestNotAfterConnect(tutils.DaemonTests): not_after_connect = True ) def test_connect(self): - r = self.pathoc(r"get:'http://foo.com/p/202':da", connect_to=("localhost", self.d.port)) + r = self.pathoc( + r"get:'http://foo.com/p/202':da", + connect_to=("localhost", self.d.port) + ) assert r.status_code == 202 @@ -157,11 +153,15 @@ class CommonTests(tutils.DaemonTests): assert l["type"] == "error" assert "foo" in l["msg"] - def test_invalid_body(self): - tutils.raises(http.HttpError, self.pathoc, "get:/:h'content-length'='foo'") + def test_invalid_content_length(self): + tutils.raises( + http.HttpError, + self.pathoc, + "get:/:h'content-length'='foo'" + ) l = self.d.last_log() assert l["type"] == "error" - assert "Invalid" in l["msg"] + assert "Content-Length unknown" in l["msg"] def test_invalid_headers(self): tutils.raises(http.HttpError, self.pathoc, "get:/:h'\t'='foo'") @@ -204,7 +204,7 @@ class TestDaemon(CommonTests): class TestDaemonSSL(CommonTests): ssl = True - def test_ssl_conn_failure(self): + def _test_ssl_conn_failure(self): c = tcp.TCPClient(("localhost", self.d.port)) c.rbufsize = 0 c.wbufsize = 0 @@ -222,4 +222,3 @@ class TestDaemonSSL(CommonTests): r = self.pathoc(r"get:/p/202") assert r.status_code == 202 assert self.d.last_log()["cipher"][1] > 0 - |