예제 #1
0
 def test_simple(self):
     if sys.platform == "freebsd10":
         p = tutils.test_data.path("mitmproxy/data/pf02")
         d = open(p, "rb").read()
     else:
         p = tutils.test_data.path("mitmproxy/data/pf01")
         d = open(p, "rb").read()
     assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
     with pytest.raises("Could not resolve original destination"):
         pf.lookup("192.168.1.112", 40000, d)
     with pytest.raises("Could not resolve original destination"):
         pf.lookup("192.168.1.111", 40001, d)
예제 #2
0
파일: test_pf.py 프로젝트: s4chin/mitmproxy
 def test_simple(self):
     if sys.platform == "freebsd10":
         p = tutils.test_data.path("mitmproxy/data/pf02")
         d = open(p, "rb").read()
     else:
         p = tutils.test_data.path("mitmproxy/data/pf01")
         d = open(p, "rb").read()
     assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
     with pytest.raises(Exception, match="Could not resolve original destination"):
         pf.lookup("192.168.1.112", 40000, d)
     with pytest.raises(Exception, match="Could not resolve original destination"):
         pf.lookup("192.168.1.111", 40001, d)
예제 #3
0
 def test_simple(self):
     if sys.platform == "freebsd10":
         p = tutils.test_data.path("data/pf02")
         d = open(p, "rb").read()
     else:
         p = tutils.test_data.path("data/pf01")
         d = open(p, "rb").read()
     assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
     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)
예제 #4
0
    def test_simple(self, tdata):
        if sys.platform == "freebsd10":
            p = tdata.path("mitmproxy/data/pf02")
        else:
            p = tdata.path("mitmproxy/data/pf01")
        with open(p, "rb") as f:
            d = f.read()

        assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
        assert pf.lookup("::ffff:192.168.1.111", 40000, d) == ("5.5.5.5", 80)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("192.168.1.112", 40000, d)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("192.168.1.111", 40001, d)
예제 #5
0
    def test_simple(self, tdata):
        if sys.platform == "freebsd10":
            p = tdata.path("mitmproxy/data/pf02")
        else:
            p = tdata.path("mitmproxy/data/pf01")
        with open(p, "rb") as f:
            d = f.read()

        assert pf.lookup("192.168.1.111", 40000, d) == ("5.5.5.5", 80)
        assert pf.lookup("::ffff:192.168.1.111", 40000, d) == ("5.5.5.5", 80)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("192.168.1.112", 40000, d)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("192.168.1.111", 40001, d)
        assert pf.lookup("2a01:e35:8bae:50f0:396f:e6c7:f4f1:f3db", 40002,
                         d) == ("2a03:2880:f21f:c5:face:b00c::167", 443)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("2a01:e35:8bae:50f0:396f:e6c7:f4f1:f3db", 40003, d)
        with pytest.raises(Exception,
                           match="Could not resolve original destination"):
            pf.lookup("2a01:e35:face:face:face:face:face:face", 40003, d)