diff options
author | Andrei Belov <defan@nginx.com> | 2020-03-12 18:40:48 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-03-12 18:40:48 +0300 |
commit | 4b7ca39903178e20ec7381205694cb01f0dec6bc (patch) | |
tree | 51afb9c7003b5927183e7ddecd766eb19e421233 /test/test_static.py | |
parent | 8414897527ed1616ea39a0cae4d1b8ee170d5cb8 (diff) | |
parent | b3c8a7b33a29208e75dfe4f670cf81dac7b99ccc (diff) | |
download | unit-4b7ca39903178e20ec7381205694cb01f0dec6bc.tar.gz unit-4b7ca39903178e20ec7381205694cb01f0dec6bc.tar.bz2 |
Merged with the default branch.1.16.0-1
Diffstat (limited to 'test/test_static.py')
-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) |