Skip to content

Commit

Permalink
Update test_B7_persist_temp_file
Browse files Browse the repository at this point in the history
Add a test case for file permissions

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
  • Loading branch information
sechkova committed Apr 16, 2020
1 parent e2d0e87 commit 33486ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_util.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,16 @@ def test_B7_persist_temp_file(self):
dest_path = os.path.join(dest_temp_dir, self.random_string())
tmpfile = tempfile.TemporaryFile()
tmpfile.write(self.random_string().encode('utf-8'))
securesystemslib.util.persist_temp_file(tmpfile, dest_path)
# Write a file with a custom umask
securesystemslib.util.persist_temp_file(tmpfile, dest_path, 0o177)
self.assertTrue(dest_path)
# Test if file permissions are as expected
# permissions = default mode (0o777) - umask
expected_perm = '600'
if os.name != 'posix':
# Windows only supports setting the read-only attribute.
expected_perm = '666'
self.assertEqual(oct(os.stat(dest_path).st_mode)[-3:], expected_perm)



Expand Down

0 comments on commit 33486ba

Please sign in to comment.