summaryrefslogtreecommitdiff
path: root/tests/unit/utils_test.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-02-05 13:11:19 -0800
committerJoffrey F <joffrey@docker.com>2018-02-05 13:11:19 -0800
commit58639aecfa50e0bcfbd1415dc8bab2b4448f4d81 (patch)
treebd44d3317859f2cdb6bf5b122fd44def1c986caa /tests/unit/utils_test.py
parent05d34ed1fbaa8233a4cf51a0f52b67aef99a9521 (diff)
downloaddocker-py-1899-create_archive_fix.tar.gz
Rewrite access check in create_archive with EAFP1899-create_archive_fix
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/unit/utils_test.py')
-rw-r--r--tests/unit/utils_test.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 1f9daf6..3139a97 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -933,7 +933,10 @@ class TarTest(unittest.TestCase):
tar_data = tarfile.open(fileobj=archive)
assert sorted(tar_data.getnames()) == ['bar', 'foo']
- @pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='No chmod on Windows')
+ @pytest.mark.skipif(
+ IS_WINDOWS_PLATFORM or os.geteuid() == 0,
+ reason='root user always has access ; no chmod on Windows'
+ )
def test_tar_with_inaccessible_file(self):
base = tempfile.mkdtemp()
full_path = os.path.join(base, 'foo')
@@ -944,8 +947,9 @@ class TarTest(unittest.TestCase):
with pytest.raises(IOError) as ei:
tar(base)
- assert 'Can not access file in context: {}'.format(full_path) in \
+ assert 'Can not read file in context: {}'.format(full_path) in (
ei.exconly()
+ )
@pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='No symlinks on Windows')
def test_tar_with_file_symlinks(self):