@@ -292,6 +292,28 @@ def test_ensure_alt_path(runner, paths, style):
292292 assert run .out == ""
293293 assert paths .work .join (filename ).read ().strip () == "test-data"
294294
295+ @pytest .mark .usefixtures ("ds1_repo_copy" )
296+ @pytest .mark .parametrize ("readonly" , [None , "true" , "false" ])
297+ def test_template_readonly (runner , yadm_cmd , paths , tst_sys , readonly ):
298+ """Remove write permission for template result file.
299+
300+ If the `yadm.template-read-only` configuration is not set to false,
301+ the resulting file from processing a template should has no write permission.
302+ """
303+ # set the value of template read-only
304+ if readonly :
305+ runner (yadm_cmd ("config" , "yadm.template-read-only" , readonly ))
306+
307+ utils .create_alt_files (paths , f"##template.default" )
308+ run = runner (yadm_cmd ("alt" ))
309+
310+ for stale_path in [utils .ALT_FILE1 , utils .ALT_FILE2 ]:
311+ write_perm_mask = os .stat (paths .work .join (stale_path )).st_mode & 0o222
312+ if readonly == "false" :
313+ assert write_perm_mask > 0
314+ else :
315+ assert write_perm_mask == 0
316+
295317
296318def setup_standard_yadm_dir (paths ):
297319 """Configure a yadm home within the work tree"""
0 commit comments