Debian Codegraph @

testsuite/operator-path-dir-daemon-inmodule_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Regression guard for the module-confinement / exclude-aware operator-path
3 # resolver: a LEGITIMATE absolute --partial-dir that lives inside the served
4 # module (a real directory, no symlink, not excluded) must still work. The
5 # out-of-module / exclude refusals must not over-block an absolute in-module
6 # path by tripping on the module root's own ancestors (/home, /srv, ...) while
7 # the ownership walk descends to it.
8
9 import subprocess
10
11 from rsyncfns import (
12 SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf,
13 )
14
15 base = SCRATCHDIR / 'inmodule'
16 rmtree(base)
17 base.mkdir()
18 mod = base / 'mod'
19 mod.mkdir()
20 (mod / 'pdir').mkdir() # a real in-module partial dir
21 (mod / 'f0').write_text("OLD\n") # existing dest, smaller than src
22 src = base / 'src'
23 src.mkdir()
24 (src / 'f0').write_text("NEW-LONGER-CONTENT-SO-IT-TRANSFERS\n")
25
26 conf = write_daemon_conf([('mod', {'path': str(mod), 'read only': 'no'})])
27 url = start_test_daemon(conf, 12908)
28
29 # Absolute in-module --partial-dir: must be accepted and the file delivered.
30 proc = subprocess.run(
31 rsync_argv('-a', f'--partial-dir={mod}/pdir', f'{src}/', f'{url}mod/'),
32 stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
33 got = (mod / 'f0').read_text() if (mod / 'f0').exists() else None
34 if got != "NEW-LONGER-CONTENT-SO-IT-TRANSFERS\n":
35 test_fail(
36 "a legitimate absolute in-module --partial-dir was over-blocked: "
37 f"dest f0 is {got!r} (rc={proc.returncode}, err={proc.stderr.strip()[:200]}). "
38 "The module-confine/exclude refusal must allow the module root's ancestors.")
39 print("legitimate absolute in-module --partial-dir is accepted")