summaryrefslogtreecommitdiffhomepage
path: root/test/test_share_symlink.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_symlink.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_symlink.py')
-rw-r--r--test/test_share_symlink.py96
1 files changed, 0 insertions, 96 deletions
diff --git a/test/test_share_symlink.py b/test/test_share_symlink.py
deleted file mode 100644
index 3970b605..00000000
--- a/test/test_share_symlink.py
+++ /dev/null
@@ -1,96 +0,0 @@
-import os
-
-import pytest
-
-from unit.applications.proto import TestApplicationProto
-
-
-class TestShareSymlink(TestApplicationProto):
- prerequisites = {'features': ['chroot']}
-
- @pytest.fixture(autouse=True)
- def setup_method_fixture(self, temp_dir):
- os.makedirs(temp_dir + '/assets/dir/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')
-
- self._load_conf(
- {
- "listeners": {"*:7080": {"pass": "routes"}},
- "routes": [{"action": {"share": temp_dir + "/assets"}}],
- }
- )
-
- def test_share_symlink(self, temp_dir, skip_alert):
- skip_alert(r'opening.*failed')
-
- os.symlink(temp_dir + '/assets/dir', temp_dir + '/assets/link')
-
- assert self.get(url='/dir')['status'] == 301, 'dir'
- assert self.get(url='/dir/file')['status'] == 200, 'file'
- assert self.get(url='/link')['status'] == 301, 'symlink dir'
- assert self.get(url='/link/file')['status'] == 200, 'symlink file'
-
- assert 'success' in self.conf(
- {"share": temp_dir + "/assets", "follow_symlinks": False},
- 'routes/0/action',
- ), 'configure symlink disable'
-
- assert self.get(url='/link/file')['status'] == 403, 'symlink disabled'
-
- assert 'success' in self.conf(
- {"share": temp_dir + "/assets", "follow_symlinks": True},
- 'routes/0/action',
- ), 'configure symlink enable'
-
- assert self.get(url='/link/file')['status'] == 200, 'symlink enabled'
-
- def test_share_symlink_two_blocks(self, temp_dir, skip_alert):
- skip_alert(r'opening.*failed')
-
- os.symlink(temp_dir + '/assets/dir', temp_dir + '/assets/link')
-
- assert 'success' in self.conf(
- [
- {
- "match": {"method": "HEAD"},
- "action": {
- "share": temp_dir + "/assets",
- "follow_symlinks": False,
- },
- },
- {
- "match": {"method": "GET"},
- "action": {
- "share": temp_dir + "/assets",
- "follow_symlinks": True,
- },
- },
- ],
- 'routes',
- ), 'configure two options'
-
- assert self.get(url='/link/file')['status'] == 200, 'block enabled'
- assert self.head(url='/link/file')['status'] == 403, 'block disabled'
-
- def test_share_symlink_chroot(self, temp_dir, skip_alert):
- skip_alert(r'opening.*failed')
-
- os.symlink(
- temp_dir + '/assets/dir/file', temp_dir + '/assets/dir/dir/link'
- )
-
- assert self.get(url='/dir/dir/link')['status'] == 200, 'default chroot'
-
- assert 'success' in self.conf(
- {
- "share": temp_dir + "/assets",
- "chroot": temp_dir + "/assets/dir/dir",
- },
- 'routes/0/action',
- ), 'configure chroot'
-
- assert self.get(url='/dir/dir/link')['status'] == 404, 'chroot'