summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormaluke <devnull@localhost>2008-05-28 10:41:46 +0000
committermaluke <devnull@localhost>2008-05-28 10:41:46 +0000
commit42b55c956e00ef0396e299ac4e44ba98187c3619 (patch)
treec8f3a50b120d94a2ab2b56aee4d856f7dd5acb08 /tests
parentc7650b9216fc51958661ac9776f8e5d92ad2a189 (diff)
downloadpaste-42b55c956e00ef0396e299ac4e44ba98187c3619.tar.gz
tests for fileapp.DirectoryApp
Diffstat (limited to 'tests')
-rw-r--r--tests/test_fileapp.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_fileapp.py b/tests/test_fileapp.py
index 000028c..e48dca1 100644
--- a/tests/test_fileapp.py
+++ b/tests/test_fileapp.py
@@ -122,6 +122,29 @@ def test_file():
import os
os.unlink(tempfile)
+def test_dir():
+ import os
+ import tempfile
+ tmpdir = tempfile.mkdtemp()
+ try:
+ tmpfile = os.path.join(tmpdir, 'file')
+ tmpsubdir = os.path.join(tmpdir, 'dir')
+ open(tmpfile, 'w').write('abcd')
+ os.mkdir(tmpsubdir)
+ try:
+ from paste import fileapp
+ app = fileapp.DirectoryApp(tmpdir)
+ for path in ['/', '', '//', '/..', '/.', '/../..']:
+ assert TestApp(app).get(path, status=403).status == 403, ValueError(path)
+ for path in ['/~', '/foo', '/dir', '/dir/']:
+ assert TestApp(app).get(path, status=404).status == 404, ValueError(path)
+ assert TestApp(app).get('/file').body == 'abcd'
+ finally:
+ os.remove(tmpfile)
+ os.rmdir(tmpsubdir)
+ finally:
+ os.rmdir(tmpdir)
+
def _excercize_range(build,content):
# full content request, but using ranges'
res = build("bytes=0-%d" % (len(content)-1))
@@ -206,4 +229,4 @@ def test_methods():
assert res.headers == get_res.headers
assert not res.body
app.post('', status=405) # Method Not Allowed
-
+