diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/pathod/test_language_base.py | 2 | ||||
| -rw-r--r-- | test/pathod/test_language_generators.py | 2 | ||||
| -rw-r--r-- | test/pathod/test_language_http.py | 7 | ||||
| -rw-r--r-- | test/pathod/test_language_http2.py | 2 | ||||
| -rw-r--r-- | test/pathod/test_language_websocket.py | 9 | ||||
| -rw-r--r-- | test/pathod/test_pathoc.py | 12 | ||||
| -rw-r--r-- | test/pathod/test_pathoc_cmdline.py | 4 | ||||
| -rw-r--r-- | test/pathod/test_pathod.py | 23 | ||||
| -rw-r--r-- | test/pathod/test_pathod_cmdline.py | 6 | ||||
| -rw-r--r-- | test/pathod/test_test.py | 6 | ||||
| -rw-r--r-- | test/pathod/test_utils.py | 2 | ||||
| -rw-r--r-- | test/pathod/tservers.py (renamed from test/pathod/tutils.py) | 10 | 
12 files changed, 40 insertions, 45 deletions
| diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py index b8abc9ba..a77aced0 100644 --- a/test/pathod/test_language_base.py +++ b/test/pathod/test_language_base.py @@ -2,7 +2,7 @@ import os  from pathod import language  from pathod.language import base, exceptions -from . import tutils +from mitmproxy.test import tutils  def parse_request(s): diff --git a/test/pathod/test_language_generators.py b/test/pathod/test_language_generators.py index 4ec6ec3f..b3ce0335 100644 --- a/test/pathod/test_language_generators.py +++ b/test/pathod/test_language_generators.py @@ -1,7 +1,7 @@  import os  from pathod.language import generators -from . import tutils +from mitmproxy.test import tutils  def test_randomgenerator(): diff --git a/test/pathod/test_language_http.py b/test/pathod/test_language_http.py index e1eabe4a..9a239bf5 100644 --- a/test/pathod/test_language_http.py +++ b/test/pathod/test_language_http.py @@ -2,7 +2,8 @@ import io  from pathod import language  from pathod.language import http, base -from . import tutils +from mitmproxy.test import tutils +from . import tservers  def parse_request(s): @@ -302,8 +303,8 @@ def test_shortcuts():      assert next(language.parse_pathod(          "400:l'foo'")).headers[0].key.val == b"Location" -    assert b"Android" in tutils.render(parse_request("get:/:ua")) -    assert b"User-Agent" in tutils.render(parse_request("get:/:ua")) +    assert b"Android" in tservers.render(parse_request("get:/:ua")) +    assert b"User-Agent" in tservers.render(parse_request("get:/:ua"))  def test_user_agent(): diff --git a/test/pathod/test_language_http2.py b/test/pathod/test_language_http2.py index 7d3a8e60..8ab1acae 100644 --- a/test/pathod/test_language_http2.py +++ b/test/pathod/test_language_http2.py @@ -7,7 +7,7 @@ from pathod import language  from pathod.language import http2  from pathod.protocols.http2 import HTTP2StateProtocol -from . import tutils +from mitmproxy.test import tutils  def parse_request(s): diff --git a/test/pathod/test_language_websocket.py b/test/pathod/test_language_websocket.py index 49fbd4e6..e61413da 100644 --- a/test/pathod/test_language_websocket.py +++ b/test/pathod/test_language_websocket.py @@ -2,7 +2,8 @@ from pathod import language  from pathod.language import websockets  import mitmproxy.net.websockets -from . import tutils +from mitmproxy.test import tutils +from . import tservers  def parse_request(s): @@ -62,7 +63,7 @@ class TestWebsocketFrame:      def test_flags(self):          wf = parse_request("wf:fin:mask:rsv1:rsv2:rsv3") -        frm = mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf)) +        frm = mitmproxy.net.websockets.Frame.from_bytes(tservers.render(wf))          assert frm.header.fin          assert frm.header.mask          assert frm.header.rsv1 @@ -70,7 +71,7 @@ class TestWebsocketFrame:          assert frm.header.rsv3          wf = parse_request("wf:-fin:-mask:-rsv1:-rsv2:-rsv3") -        frm = mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf)) +        frm = mitmproxy.net.websockets.Frame.from_bytes(tservers.render(wf))          assert not frm.header.fin          assert not frm.header.mask          assert not frm.header.rsv1 @@ -80,7 +81,7 @@ class TestWebsocketFrame:      def fr(self, spec, **kwargs):          settings = language.base.Settings(**kwargs)          wf = parse_request(spec) -        return mitmproxy.net.websockets.Frame.from_bytes(tutils.render(wf, settings)) +        return mitmproxy.net.websockets.Frame.from_bytes(tservers.render(wf, settings))      def test_construction(self):          assert self.fr("wf:c1").header.opcode == 1 diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index 90177ff6..69baae54 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -4,13 +4,13 @@ from mock import Mock  from mitmproxy.net import http  from mitmproxy.net import tcp  from mitmproxy.net.http import http1 -from mitmproxy.test.tutils import raises  from mitmproxy import exceptions  from pathod import pathoc, language  from pathod.protocols.http2 import HTTP2StateProtocol -from . import tutils +from mitmproxy.test import tutils +from . import tservers  def test_response(): @@ -18,7 +18,7 @@ def test_response():      assert repr(r) -class PathocTestDaemon(tutils.DaemonTests): +class PathocTestDaemon(tservers.DaemonTests):      def tval(self, requests, timeout=None, showssl=False, **kwargs):          s = io.StringIO()          c = pathoc.Pathoc( @@ -64,7 +64,7 @@ class TestDaemonSSL(PathocTestDaemon):      def test_clientcert(self):          self.tval(              ["get:/p/200"], -            clientcert=tutils.test_data.path("data/clientcert/client.pem"), +            clientcert=tutils.test_data.path("pathod/data/clientcert/client.pem"),          )          log = self.d.log()          assert log[0]["request"]["clientcert"]["keyinfo"] @@ -171,12 +171,12 @@ class TestDaemon(PathocTestDaemon):          to = ("foobar", 80)          c = pathoc.Pathoc(("127.0.0.1", self.d.port), fp=None)          c.rfile, c.wfile = io.BytesIO(), io.BytesIO() -        with raises("connect failed"): +        with tutils.raises("connect failed"):              c.http_connect(to)          c.rfile = io.BytesIO(              b"HTTP/1.1 500 OK\r\n"          ) -        with raises("connect failed"): +        with tutils.raises("connect failed"):              c.http_connect(to)          c.rfile = io.BytesIO(              b"HTTP/1.1 200 OK\r\n" diff --git a/test/pathod/test_pathoc_cmdline.py b/test/pathod/test_pathoc_cmdline.py index 7f51929f..3b54403f 100644 --- a/test/pathod/test_pathoc_cmdline.py +++ b/test/pathod/test_pathoc_cmdline.py @@ -3,7 +3,7 @@ import mock  from pathod import pathoc_cmdline as cmdline -from . import tutils +from mitmproxy.test import tutils  @mock.patch("argparse.ArgumentParser.error") @@ -52,7 +52,7 @@ def test_pathoc(perror):          [              "pathoc",              "foo.com:8888", -            tutils.test_data.path("data/request") +            tutils.test_data.path("pathod/data/request")          ]      )      assert len(list(a.requests)) == 1 diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 8ee7a2fd..6a4e1c62 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -3,8 +3,9 @@ import io  from pathod import pathod  from mitmproxy.net import tcp  from mitmproxy import exceptions +from mitmproxy.test import tutils -from . import tutils +from . import tservers  class TestPathod: @@ -24,7 +25,7 @@ class TestPathod:          assert len(p.get_log()) <= p.LOGBUF -class TestTimeout(tutils.DaemonTests): +class TestTimeout(tservers.DaemonTests):      timeout = 0.01      def test_timeout(self): @@ -36,7 +37,7 @@ class TestTimeout(tutils.DaemonTests):          assert self.d.last_log()["type"] == "timeout" -class TestNotAfterConnect(tutils.DaemonTests): +class TestNotAfterConnect(tservers.DaemonTests):      ssl = False      ssloptions = dict(          not_after_connect=True @@ -50,10 +51,10 @@ class TestNotAfterConnect(tutils.DaemonTests):          assert r[0].status_code == 202 -class TestCustomCert(tutils.DaemonTests): +class TestCustomCert(tservers.DaemonTests):      ssl = True      ssloptions = dict( -        certs=[(b"*", tutils.test_data.path("data/testkey.pem"))], +        certs=[(b"*", tutils.test_data.path("pathod/data/testkey.pem"))],      )      def test_connect(self): @@ -64,7 +65,7 @@ class TestCustomCert(tutils.DaemonTests):          assert "test.com" in str(r.sslinfo.certchain[0].get_subject()) -class TestSSLCN(tutils.DaemonTests): +class TestSSLCN(tservers.DaemonTests):      ssl = True      ssloptions = dict(          cn=b"foo.com" @@ -78,7 +79,7 @@ class TestSSLCN(tutils.DaemonTests):          assert r.sslinfo.certchain[0].get_subject().CN == "foo.com" -class TestNohang(tutils.DaemonTests): +class TestNohang(tservers.DaemonTests):      nohang = True      def test_nohang(self): @@ -88,14 +89,14 @@ class TestNohang(tutils.DaemonTests):          assert "Pauses have been disabled" in l["response"]["msg"] -class TestHexdump(tutils.DaemonTests): +class TestHexdump(tservers.DaemonTests):      hexdump = True      def test_hexdump(self):          assert self.get(r"200:b'\xf0'") -class TestNocraft(tutils.DaemonTests): +class TestNocraft(tservers.DaemonTests):      nocraft = True      def test_nocraft(self): @@ -104,7 +105,7 @@ class TestNocraft(tutils.DaemonTests):          assert b"Crafting disabled" in r.content -class CommonTests(tutils.DaemonTests): +class CommonTests(tservers.DaemonTests):      def test_binarydata(self):          assert self.get(r"200:b'\xf0'") @@ -252,7 +253,7 @@ class TestDaemonSSL(CommonTests):          assert self.d.last_log()["cipher"][1] > 0 -class TestHTTP2(tutils.DaemonTests): +class TestHTTP2(tservers.DaemonTests):      ssl = True      nohang = True diff --git a/test/pathod/test_pathod_cmdline.py b/test/pathod/test_pathod_cmdline.py index 58123b37..290f5d9f 100644 --- a/test/pathod/test_pathod_cmdline.py +++ b/test/pathod/test_pathod_cmdline.py @@ -2,7 +2,7 @@ import mock  from pathod import pathod_cmdline as cmdline -from . import tutils +from mitmproxy.test import tutils  def test_parse_anchor_spec(): @@ -18,7 +18,7 @@ def test_pathod(perror):          [              "pathod",              "--cert", -            tutils.test_data.path("data/testkey.pem") +            tutils.test_data.path("pathod/data/testkey.pem")          ]      )      assert a.ssl_certs @@ -46,7 +46,7 @@ def test_pathod(perror):          [              "pathod",              "-a", -            "foo=" + tutils.test_data.path("data/response") +            "foo=" + tutils.test_data.path("pathod/data/response")          ]      )      assert a.anchors diff --git a/test/pathod/test_test.py b/test/pathod/test_test.py index d69e72f3..c2e1c6e9 100644 --- a/test/pathod/test_test.py +++ b/test/pathod/test_test.py @@ -2,7 +2,7 @@ import logging  import requests  from pathod import test -from . import tutils +from mitmproxy.test import tutils  import requests.packages.urllib3 @@ -34,8 +34,8 @@ class TestDaemonManual:      def test_startstop_ssl_explicit(self):          ssloptions = dict( -            certfile=tutils.test_data.path("data/testkey.pem"), -            cacert=tutils.test_data.path("data/testkey.pem"), +            certfile=tutils.test_data.path("pathod/data/testkey.pem"), +            cacert=tutils.test_data.path("pathod/data/testkey.pem"),              ssl_after_connect=False          )          d = test.Daemon(ssl=ssloptions) diff --git a/test/pathod/test_utils.py b/test/pathod/test_utils.py index 2bdfe501..80fc2ed8 100644 --- a/test/pathod/test_utils.py +++ b/test/pathod/test_utils.py @@ -1,6 +1,6 @@  from pathod import utils -from . import tutils +from mitmproxy.test import tutils  def test_membool(): diff --git a/test/pathod/tutils.py b/test/pathod/tservers.py index ccc3df43..fab09288 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tservers.py @@ -5,7 +5,6 @@ import requests  import io  import urllib -from mitmproxy.utils import data  from mitmproxy.net import tcp  from mitmproxy.test import tutils @@ -40,7 +39,7 @@ class DaemonTests:          opts["confdir"] = cls.confdir          so = pathod.SSLOptions(**opts)          cls.d = test.Daemon( -            staticdir=test_data.path("data"), +            staticdir=tutils.test_data.path("pathod/data"),              anchors=[                  (re.compile("/anchor/.*"), "202:da")              ], @@ -139,13 +138,6 @@ class DaemonTests:              return ret, logfp.getvalue() -tmpdir = tutils.tmpdir - -raises = tutils.raises - -test_data = data.Data(__name__) - -  def render(r, settings=language.Settings()):      r = r.resolve(settings)      s = io.BytesIO() | 
