Skip to content

Commit

Permalink
selftests: Handle superuser in test_archive correctly
Browse files Browse the repository at this point in the history
The superusers default permission is 0o644 while other users is 0o664.
This is not handled by zipfile yet so adjust the unittest for now and
see what we can do about this in our utils.archive later.

Signed-off-by: Lukáš Doktor <[email protected]>
  • Loading branch information
ldoktor committed Jul 4, 2016
1 parent c80fb3a commit 8f681f9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions selftests/unit/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def get_path(*args):
zip_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
os.path.pardir, ".data",
"test_archive__symlinks.zip"))
# TODO: Handle permission correctly for all users
# The umask is not yet handled by utils.archive, hardcode it for now
os.umask(2)
archive.uncompress(zip_path, self.decompressdir)
self.assertTrue(os.path.islink(get_path("link_to_dir")))
self.assertTrue(os.path.islink(get_path("link_to_file")))
Expand All @@ -125,15 +128,12 @@ def get_path(*args):
self.assertEqual(os.path.realpath(get_path("link_to_dir")),
get_path("dir"))
# File permissions
# TODO: Handle permission correctly for all users
# Default perm by user is 0o664 and by root 0o644
default_perm = 0o664 if os.getuid() else 0o644
self.assertEqual(os.stat(get_path("dir", "file2")).st_mode & 0o777,
default_perm)
0o664)
self.assertEqual(os.stat(get_path("file")).st_mode & 0o777, 0o753)
self.assertEqual(os.stat(get_path("dir")).st_mode & 0o777, 0o775)
self.assertEqual(os.stat(get_path("link_to_file2")).st_mode & 0o777,
default_perm)
0o664)
self.assertEqual(os.stat(get_path("link_to_dir")).st_mode & 0o777,
0o775)
self.assertEqual(os.stat(get_path("link_to_file")).st_mode & 0o777,
Expand Down

0 comments on commit 8f681f9

Please sign in to comment.