summaryrefslogtreecommitdiffhomepage
path: root/test/test_share_chroot.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-06-28 22:05:40 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2021-06-28 22:05:40 +0100
commitb86891c4ef848a2da05abd1350af5f0b8e4335fa (patch)
tree38dccefa03558d95014a2fd14a6d8cc85e380473 /test/test_share_chroot.py
parent72420358be128640dd09a0914a8d88b50c152545 (diff)
downloadunit-b86891c4ef848a2da05abd1350af5f0b8e4335fa.tar.gz
unit-b86891c4ef848a2da05abd1350af5f0b8e4335fa.tar.bz2
Tests: renamed share to static.
Also minor style changes.
Diffstat (limited to 'test/test_share_chroot.py')
-rw-r--r--test/test_share_chroot.py111
1 files changed, 0 insertions, 111 deletions
diff --git a/test/test_share_chroot.py b/test/test_share_chroot.py
deleted file mode 100644
index 02b3657d..00000000
--- a/test/test_share_chroot.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import os
-from pathlib import Path
-
-import pytest
-
-from unit.applications.proto import TestApplicationProto
-
-
-class TestShareChroot(TestApplicationProto):
- prerequisites = {'features': ['chroot']}
-
- @pytest.fixture(autouse=True)
- def setup_method_fixture(self, temp_dir):
- os.makedirs(temp_dir + '/assets/dir')
- with open(temp_dir + '/assets/index.html', 'w') as index, open(
- temp_dir + '/assets/dir/file', 'w'
- ) as file:
- index.write('0123456789')
- file.write('blah')
-
- test = Path(__file__)
- self.test_path = '/' + test.parent.name + '/' + test.name
-
- self._load_conf(
- {
- "listeners": {"*:7080": {"pass": "routes"}},
- "routes": [{"action": {"share": temp_dir + "/assets"}}],
- }
- )
-
- def test_share_chroot(self, temp_dir):
- assert self.get(url='/dir/file')['status'] == 200, 'default chroot'
- assert self.get(url='/index.html')['status'] == 200, 'default chroot 2'
-
- assert 'success' in self.conf(
- {
- "share": temp_dir + "/assets",
- "chroot": temp_dir + "/assets/dir",
- },
- 'routes/0/action',
- ), 'configure chroot'
-
- assert self.get(url='/dir/file')['status'] == 200, 'chroot'
- assert self.get(url='/index.html')['status'] == 403, 'chroot 403 2'
- assert self.get(url='/file')['status'] == 403, 'chroot 403'
-
- def test_share_chroot_permission(self, is_su, temp_dir):
- if is_su:
- pytest.skip('does\'t work under root')
-
- os.chmod(temp_dir + '/assets/dir', 0o100)
-
- assert 'success' in self.conf(
- {
- "share": temp_dir + "/assets",
- "chroot": temp_dir + "/assets/dir",
- },
- 'routes/0/action',
- ), 'configure chroot'
-
- assert self.get(url='/dir/file')['status'] == 200, 'chroot'
-
- def test_share_chroot_empty(self, temp_dir):
- assert 'success' in self.conf(
- {"share": temp_dir + "/assets", "chroot": ""}, 'routes/0/action',
- ), 'configure chroot empty absolute'
-
- assert (
- self.get(url='/dir/file')['status'] == 200
- ), 'chroot empty absolute'
-
- assert 'success' in self.conf(
- {"share": ".", "chroot": ""}, 'routes/0/action',
- ), 'configure chroot empty relative'
-
- assert (
- self.get(url=self.test_path)['status'] == 200
- ), 'chroot empty relative'
-
- def test_share_chroot_relative(self, is_su, temp_dir):
- if is_su:
- pytest.skip('does\'t work under root')
-
- assert 'success' in self.conf(
- {"share": temp_dir + "/assets", "chroot": "."}, 'routes/0/action',
- ), 'configure relative chroot'
-
- assert self.get(url='/dir/file')['status'] == 403, 'relative chroot'
-
- assert 'success' in self.conf(
- {"share": "."}, 'routes/0/action',
- ), 'configure relative share'
-
- assert self.get(url=self.test_path)['status'] == 200, 'relative share'
-
- assert 'success' in self.conf(
- {"share": ".", "chroot": "."}, 'routes/0/action',
- ), 'configure relative'
-
- assert self.get(url=self.test_path)['status'] == 200, 'relative'
-
- def test_share_chroot_invalid(self, temp_dir):
- assert 'error' in self.conf(
- {"share": temp_dir, "chroot": True}, 'routes/0/action',
- ), 'configure chroot error'
- assert 'error' in self.conf(
- {"share": temp_dir, "symlinks": "True"}, 'routes/0/action',
- ), 'configure symlink error'
- assert 'error' in self.conf(
- {"share": temp_dir, "mount": "True"}, 'routes/0/action',
- ), 'configure mount error'