aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_proxy.py')
-rw-r--r--test/test_proxy.py74
1 files changed, 1 insertions, 73 deletions
diff --git a/test/test_proxy.py b/test/test_proxy.py
index 00857586..e5b3ed16 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -1,75 +1,9 @@
-import urllib, urllib2, cStringIO
+import cStringIO
import libpry
from libmproxy import proxy, controller, utils, dump, script
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)
- 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)
- assert f.read()
-
-
-class uProxy(tutils.ProxTest):
- HOST = "127.0.0.1"
- def _get(self, host=HOST):
- r = urllib2.Request("http://%s:%s"%(host, tutils.HTTP_PORT))
- r.set_proxy("127.0.0.1:%s"%tutils.PROXL_PORT, "http")
- return urllib2.urlopen(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
- assert f.read()
- f.close()
-
- l = self.log()
- assert l[0].address
- assert l[1].headers.has_key("host")
- 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 l[1].headers.has_key("host")
- 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()
-
-
-
class u_parse_request_line(libpry.AutoTree):
def test_simple(self):
libpry.raises(proxy.ProxyError, proxy.parse_request_line, "")
@@ -202,7 +136,6 @@ class uError(libpry.AutoTree):
assert e == e2
-
class uProxyError(libpry.AutoTree):
def test_simple(self):
p = proxy.ProxyError(111, "msg")
@@ -221,7 +154,6 @@ class uClientConnect(libpry.AutoTree):
assert c == c2
-
tests = [
uProxyError(),
uRequest(),
@@ -231,8 +163,4 @@ tests = [
u_parse_url(),
uError(),
uClientConnect(),
- tutils.TestServers(), [
- uSanity(),
- uProxy(),
- ],
]