diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-02-21 15:08:38 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-02-21 15:08:38 +0000 |
commit | f519e31e2d97492d85aee13451554527540ccd90 (patch) | |
tree | 07455e3b69648d2227cbd9961d2389d9433d0e92 /test | |
parent | 5406d1e320eca0a94eeffe2e57e2e2b4d989e0d1 (diff) | |
download | unit-f519e31e2d97492d85aee13451554527540ccd90.tar.gz unit-f519e31e2d97492d85aee13451554527540ccd90.tar.bz2 |
Tests: more static tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_static.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/test/test_static.py b/test/test_static.py index f9dcb7dd..b2489aa0 100644 --- a/test/test_static.py +++ b/test/test_static.py @@ -39,6 +39,9 @@ class TestStatic(TestApplicationProto): self.get(url='/index.html')['body'], '0123456789', 'index' ) self.assertEqual(self.get(url='/')['body'], '0123456789', 'index 2') + self.assertEqual(self.get(url='//')['body'], '0123456789', 'index 3') + self.assertEqual(self.get(url='/.')['body'], '0123456789', 'index 4') + self.assertEqual(self.get(url='/./')['body'], '0123456789', 'index 5') self.assertEqual( self.get(url='/?blah')['body'], '0123456789', 'index vars' ) @@ -199,10 +202,29 @@ class TestStatic(TestApplicationProto): self.get(url='/link/file')['status'], 200, 'symlink file' ) - def test_static_head(self): - resp = self.head(url='/') - self.assertEqual(resp['status'], 200, 'status') - self.assertEqual(resp['body'], '', 'empty body') + def test_static_method(self): + resp = self.head() + self.assertEqual(resp['status'], 200, 'HEAD status') + self.assertEqual(resp['body'], '', 'HEAD empty body') + + self.assertEqual(self.delete()['status'], 405, 'DELETE') + self.assertEqual(self.post()['status'], 405, 'POST') + self.assertEqual(self.put()['status'], 405, 'PUT') + + def test_static_path(self): + self.assertEqual( + self.get(url='/dir/../dir/file')['status'], 200, 'relative' + ) + + self.assertEqual(self.get(url='./')['status'], 400, 'path invalid') + self.assertEqual(self.get(url='../')['status'], 400, 'path invalid 2') + self.assertEqual(self.get(url='/..')['status'], 400, 'path invalid 3') + self.assertEqual( + self.get(url='../assets/')['status'], 400, 'path invalid 4' + ) + self.assertEqual( + self.get(url='/../assets/')['status'], 400, 'path invalid 5' + ) def test_static_two_clients(self): _, sock = self.get(url='/', start=True, no_recv=True) |