|
|
|
@ -292,6 +292,28 @@ def test_ensure_alt_path(runner, paths, style):
|
|
|
|
|
assert run.out == ""
|
|
|
|
|
assert paths.work.join(filename).read().strip() == "test-data"
|
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures("ds1_repo_copy")
|
|
|
|
|
@pytest.mark.parametrize("readonly", [None, "true", "false"])
|
|
|
|
|
def test_template_readonly(runner, yadm_cmd, paths, tst_sys, readonly):
|
|
|
|
|
"""Remove write permission for template result file.
|
|
|
|
|
|
|
|
|
|
If the `yadm.template-read-only` configuration is not set to false,
|
|
|
|
|
the resulting file from processing a template should has no write permission.
|
|
|
|
|
"""
|
|
|
|
|
# set the value of template read-only
|
|
|
|
|
if readonly:
|
|
|
|
|
runner(yadm_cmd("config", "yadm.template-read-only", readonly))
|
|
|
|
|
|
|
|
|
|
utils.create_alt_files(paths, f"##template.default")
|
|
|
|
|
run = runner(yadm_cmd("alt"))
|
|
|
|
|
|
|
|
|
|
for stale_path in [utils.ALT_FILE1, utils.ALT_FILE2]:
|
|
|
|
|
write_perm_mask = os.stat(paths.work.join(stale_path)).st_mode & 0o222
|
|
|
|
|
if readonly == "false":
|
|
|
|
|
assert write_perm_mask > 0
|
|
|
|
|
else:
|
|
|
|
|
assert write_perm_mask == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_standard_yadm_dir(paths):
|
|
|
|
|
"""Configure a yadm home within the work tree"""
|
|
|
|
|