mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-08 02:19:35 +00:00
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:
20
tests/utils/test_json.py
Normal file
20
tests/utils/test_json.py
Normal 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"
|
||||
Reference in New Issue
Block a user