Files
Nexus/tests/test_nexus_files_sudoers.py
T
Nexus Agent 84b388fae2 fix(sync): rsync 推送非 root 自动 sudo 提权
文件推送与文件管理对齐:非 root 默认 auto_sudo 时使用 sudo -n rsync;
新增批量 sudoers 补丁脚本以补全 rsync 白名单。
2026-06-11 23:20:45 +08:00

18 lines
625 B
Python

"""Tests for nexus-files sudoers template and batch patch helpers."""
from server.application.services.files_sudoers_service import build_nexus_files_sudoers
def test_build_nexus_files_sudoers_includes_rsync():
content = build_nexus_files_sudoers("ubuntu")
assert "ubuntu ALL=(root) NOPASSWD:" in content
assert "/usr/bin/rsync" in content
assert "/bin/rsync" in content
assert "/usr/bin/chmod" in content
def test_build_nexus_files_sudoers_strips_user():
content = build_nexus_files_sudoers(" deploy ")
assert content.startswith("# nexus-files:")
assert "deploy ALL=(root)" in content