diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-22 23:37:46 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-22 23:37:46 +1200 |
commit | 1b03fd6780f69f1d1f460868d5592587cb0c9c50 (patch) | |
tree | 13a588c54e0ed2992963abab2fa15b872ac61606 /test/test_rparse.py | |
parent | 33208b87205e08b97af07ed6a55c999990a1b8dc (diff) | |
download | mitmproxy-1b03fd6780f69f1d1f460868d5592587cb0c9c50.tar.gz mitmproxy-1b03fd6780f69f1d1f460868d5592587cb0c9c50.tar.bz2 mitmproxy-1b03fd6780f69f1d1f460868d5592587cb0c9c50.zip |
Allow execution of specs from file, using +./path
Diffstat (limited to 'test/test_rparse.py')
-rw-r--r-- | test/test_rparse.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/test/test_rparse.py b/test/test_rparse.py index 8d157a10..f3dc7367 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -229,6 +229,12 @@ class TestPauses: class TestParseRequest: + def test_file(self): + p = tutils.test_data.path("data") + d = dict(staticdir=p) + r = rparse.parse_request(d, "+request") + assert r.path == "/foo" + def test_err(self): tutils.raises(rparse.ParseException, rparse.parse_request, {}, 'GET') @@ -266,9 +272,9 @@ class TestParseRequest: GET "/foo - - - + + + bar" ir,@1 @@ -394,6 +400,12 @@ class TestResponse: def dummy_response(self): return rparse.parse_response({}, "400'msg'") + def test_file(self): + p = tutils.test_data.path("data") + d = dict(staticdir=p) + r = rparse.parse_response(d, "+response") + assert r.code == 202 + def test_response(self): r = rparse.parse_response({}, "400'msg'") assert r.code == 400 @@ -417,3 +429,18 @@ class TestResponse: testlen(rparse.parse_response({}, "400'msg'")) testlen(rparse.parse_response({}, "400'msg':h'foo'='bar'")) testlen(rparse.parse_response({}, "400'msg':h'foo'='bar':b@100b")) + + + +def test_read_file(): + tutils.raises(rparse.FileAccessDenied, rparse.read_file, {}, "=/foo") + p = tutils.test_data.path("data") + d = dict(staticdir=p) + assert rparse.read_file(d, "+./file").strip() == "testfile" + assert rparse.read_file(d, "+file").strip() == "testfile" + tutils.raises(rparse.FileAccessDenied, rparse.read_file, d, "+./nonexistent") + tutils.raises(rparse.FileAccessDenied, rparse.read_file, d, "+/nonexistent") + + tutils.raises(rparse.FileAccessDenied, rparse.read_file, d, "+../test_rparse.py") + d["unconstrained_file_access"] = True + assert rparse.read_file(d, "+../test_rparse.py") |