Set permissions on JSON files (#2093)

* Set 600 premissions on json files

* Add test

* Fix local tar tests

* Fix tar test in action

* Use pytest fixture for tmp_path in tests

* remove not needed things
This commit is contained in:
Joakim Sørensen
2020-10-05 15:14:09 +02:00
committed by GitHub
parent 8d75583a07
commit f35b6d0b00
4 changed files with 84 additions and 62 deletions

20
tests/utils/test_json.py Normal file
View File

@@ -0,0 +1,20 @@
"""test json."""
from supervisor.utils.json import write_json_file
def test_file_permissions(tmp_path):
"""Test file permissions."""
tempfile = tmp_path / "test.json"
write_json_file(tempfile, {"test": "data"})
assert tempfile.is_file()
assert oct(tempfile.stat().st_mode)[-3:] == "600"
def test_new_file_permissions(tmp_path):
"""Test file permissions."""
tempfile = tmp_path / "test.json"
tempfile.write_text("test")
assert oct(tempfile.stat().st_mode)[-3:] != "600"
write_json_file(tempfile, {"test": "data"})
assert oct(tempfile.stat().st_mode)[-3:] == "600"