Add test case for output file permissions

Refs #14979
This commit is contained in:
Pedro Algarvio 2014-08-20 02:28:13 +01:00
parent 02c1bfaa3e
commit b6e259c21e

View file

@ -276,6 +276,43 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
if os.path.isdir(config_dir):
shutil.rmtree(config_dir)
def test_issue_14979_output_file_permissions(self):
output_file = os.path.join(integration.TMP, 'issue-14979')
current_umask = os.umask(0077)
try:
# Let's create an initial output file with some data
self.run_script(
'salt-call',
'-c {0} --output-file={1} -g'.format(
self.get_config_dir(),
output_file
),
catch_stderr=True,
with_retcode=True
)
stat1 = os.stat(output_file)
# Let's change umask
os.umask(0777)
self.run_script(
'salt-call',
'-c {0} --output-file={1} -g'.format(
self.get_config_dir(),
output_file
),
catch_stderr=True,
with_retcode=True
)
stat2 = os.stat(output_file)
self.assertEqual(stat1.st_mode, stat2.st_mode)
self.assertEqual(stat1.st_ctime, stat2.st_ctime)
finally:
if os.path.exists(output_file):
os.unlink(output_file)
# Restore umask
os.umask(current_umask)
if __name__ == '__main__':
from integration import run_tests