2012-07-15 20:42:45 +00:00
|
|
|
from libmproxy import proxy
|
2012-06-09 01:42:43 +00:00
|
|
|
import tutils
|
2010-02-16 04:09:07 +00:00
|
|
|
|
2012-06-10 04:49:59 +00:00
|
|
|
|
2012-07-08 22:58:28 +00:00
|
|
|
def test_proxy_error():
|
|
|
|
p = proxy.ProxyError(111, "msg")
|
|
|
|
assert str(p)
|
2010-02-16 04:09:07 +00:00
|
|
|
|
2012-06-18 22:42:55 +00:00
|
|
|
|
2012-07-08 22:58:28 +00:00
|
|
|
def test_app_registry():
|
|
|
|
ar = proxy.AppRegistry()
|
|
|
|
ar.add("foo", "domain", 80)
|
2012-06-18 22:42:55 +00:00
|
|
|
|
2012-07-08 22:58:28 +00:00
|
|
|
r = tutils.treq()
|
|
|
|
r.host = "domain"
|
|
|
|
r.port = 80
|
|
|
|
assert ar.get(r)
|
2012-06-18 22:42:55 +00:00
|
|
|
|
2012-07-08 22:58:28 +00:00
|
|
|
r.port = 81
|
|
|
|
assert not ar.get(r)
|
2012-07-10 03:53:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
r = tutils.treq()
|
|
|
|
r.host = "domain2"
|
|
|
|
r.port = 80
|
|
|
|
assert not ar.get(r)
|
|
|
|
r.headers["host"] = ["domain"]
|
|
|
|
assert ar.get(r)
|