| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import subprocess |
| 9 |
|
| 10 |
from rsyncfns import ( |
| 11 |
CHKDIR, FROMDIR, SCRATCHDIR, TODIR, |
| 12 |
build_rsyncd_conf, checkit, hands_setup, rmtree, |
| 13 |
rsync_argv, run_rsync, start_test_daemon, test_fail, |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
DAEMON_PORT = 12876 |
| 18 |
|
| 19 |
conf = build_rsyncd_conf() |
| 20 |
|
| 21 |
with open(conf, 'a') as f: |
| 22 |
f.write(f""" |
| 23 |
[no-compress] |
| 24 |
\tpath = {FROMDIR} |
| 25 |
\tread only = yes |
| 26 |
\trefuse options = compress |
| 27 |
""") |
| 28 |
|
| 29 |
hands_setup() |
| 30 |
run_rsync('-av', '--exclude=foobar.baz', f'{FROMDIR}/', f'{CHKDIR}/') |
| 31 |
|
| 32 |
url = start_test_daemon(conf, DAEMON_PORT) + 'no-compress/' |
| 33 |
|
| 34 |
|
| 35 |
errlog = SCRATCHDIR / 'refuse.err' |
| 36 |
proc = subprocess.run( |
| 37 |
rsync_argv('-avz', url, f'{TODIR}/'), |
| 38 |
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True, |
| 39 |
) |
| 40 |
errlog.write_text(proc.stderr) |
| 41 |
if proc.returncode == 0: |
| 42 |
print(proc.stderr) |
| 43 |
test_fail("compressed transfer was not refused") |
| 44 |
if '--compress' not in proc.stderr: |
| 45 |
print(proc.stderr) |
| 46 |
test_fail("expected refuse error mentioning --compress") |
| 47 |
|
| 48 |
|
| 49 |
rmtree(TODIR) |
| 50 |
TODIR.mkdir() |
| 51 |
checkit(['-av', url, f'{TODIR}/'], CHKDIR, TODIR, |
| 52 |
allowed_codes=(0, 23)) |