aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_server.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-08 10:00:16 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-08 10:00:16 +1200
commit7a312546f3185a2cff36a4f422c852b15b182140 (patch)
treeb536fe0be7b90750d12adc8331fba1e226eb3f03 /test/test_server.py
parent903038b8de47cbe79fefec410b8f8913d44a5178 (diff)
downloadmitmproxy-7a312546f3185a2cff36a4f422c852b15b182140.tar.gz
mitmproxy-7a312546f3185a2cff36a4f422c852b15b182140.tar.bz2
mitmproxy-7a312546f3185a2cff36a4f422c852b15b182140.zip
Shift mitmproxy test suite over to pathod.
This opens a whole brave new world of testing for mitmproxy.
Diffstat (limited to 'test/test_server.py')
-rw-r--r--test/test_server.py63
1 files changed, 9 insertions, 54 deletions
diff --git a/test/test_server.py b/test/test_server.py
index 50f1afe8..3bfbab5b 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -1,40 +1,15 @@
import urllib, urllib2
+import libpathod.test, requests
+import libpry
import tutils
class uSanity(tutils.ProxTest):
def test_http(self):
- """
- Just check that the HTTP server is running.
- """
- f = urllib.urlopen("http://127.0.0.1:%s"%tutils.HTTP_PORT, proxies={})
- assert f.read()
-
- def test_https(self):
- """
- Just check that the HTTPS server is running.
- """
- f = urllib.urlopen("https://127.0.0.1:%s"%tutils.HTTPS_PORT, proxies={})
- assert f.read()
+ assert self.pathod("205").status_code == 205
+ assert self.log()
class uProxy(tutils.ProxTest):
- HOST = "127.0.0.1"
- def _get(self, host=HOST):
- proxy_support = urllib2.ProxyHandler(
- {"http" : "http://127.0.0.1:%s"%tutils.PROXL_PORT}
- )
- opener = urllib2.build_opener(proxy_support)
- r = urllib2.Request("http://%s:%s"%(host, tutils.HTTP_PORT))
- return opener.open(r)
-
- def _sget(self, host=HOST):
- proxy_support = urllib2.ProxyHandler(
- {"https" : "https://127.0.0.1:%s"%tutils.PROXL_PORT}
- )
- opener = urllib2.build_opener(proxy_support)
- r = urllib2.Request("https://%s:%s"%(host, tutils.HTTPS_PORT))
- return opener.open(r)
-
def test_http(self):
f = self._get()
assert f.code == 200
@@ -46,32 +21,12 @@ class uProxy(tutils.ProxTest):
assert "host" in l[1].headers
assert l[2].code == 200
- def test_https(self):
- f = self._sget()
- assert f.code == 200
- assert f.read()
- f.close()
-
- l = self.log()
- assert l[0].address
- assert "host" in l[1].headers
- assert l[2].code == 200
-
- # Disable these two for now: they take a long time.
- def _test_http_nonexistent(self):
- f = self._get("nonexistent")
- assert f.code == 200
- assert "Error" in f.read()
-
- def _test_https_nonexistent(self):
- f = self._sget("nonexistent")
- assert f.code == 200
- assert "Error" in f.read()
-
tests = [
- tutils.TestServers(), [
+ tutils.TestServer(), [
+ uSanity(),
+ ],
+ tutils.TestServer(ssl=True), [
uSanity(),
- uProxy(),
- ]
+ ],
]