2015-05-30 00:03:28 +00:00
|
|
|
import tutils
|
|
|
|
import sys
|
2012-12-31 22:13:56 +00:00
|
|
|
from libmproxy.platform import pf
|
|
|
|
|
|
|
|
|
|
|
|
class TestLookup:
|
2016-01-27 09:12:18 +00:00
|
|
|
|
2012-12-31 22:13:56 +00:00
|
|
|
def test_simple(self):
|
2014-07-01 23:33:48 +00:00
|
|
|
if sys.platform == "freebsd10":
|
|
|
|
p = tutils.test_data.path("data/pf02")
|
2015-05-30 00:03:28 +00:00
|
|
|
d = open(p, "rb").read()
|
2014-07-01 23:33:48 +00:00
|
|
|
else:
|
|
|
|
p = tutils.test_data.path("data/pf01")
|
2015-05-30 00:03:28 +00:00
|
|
|
d = open(p, "rb").read()
|
2012-12-31 22:13:56 +00:00
|
|
|
assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
|
2015-05-30 00:03:28 +00:00
|
|
|
tutils.raises(
|
|
|
|
"Could not resolve original destination",
|
|
|
|
pf.lookup,
|
|
|
|
"192.168.1.112",
|
|
|
|
40000,
|
|
|
|
d)
|
|
|
|
tutils.raises(
|
|
|
|
"Could not resolve original destination",
|
|
|
|
pf.lookup,
|
|
|
|
"192.168.1.111",
|
|
|
|
40001,
|
|
|
|
d)
|