mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor backend module architecture
This commit is contained in:
@@ -38,17 +38,17 @@ def _run_permission_case(tmp_path: Path, body: str, env: dict[str, str] | None =
|
||||
fake_bin = _write_fake_chown(tmp_path)
|
||||
chown_log = tmp_path / "chown.log"
|
||||
app_dir = tmp_path / "app"
|
||||
helper_dir = app_dir / "app" / "helper"
|
||||
resource_dir = app_dir / "app" / "infrastructure"
|
||||
public_dir = tmp_path / "public"
|
||||
home_dir = tmp_path / "home"
|
||||
(app_dir / "app" / "plugins").mkdir(parents=True)
|
||||
helper_dir.mkdir(parents=True)
|
||||
resource_dir.mkdir(parents=True)
|
||||
public_dir.mkdir()
|
||||
(home_dir / ".cloakbrowser").mkdir(parents=True)
|
||||
(home_dir / "runtime").mkdir()
|
||||
(app_dir / "app" / "plugins" / "plugin.py").write_text("# plugin\n", encoding="utf-8")
|
||||
(helper_dir / "user.sites.v3.bin").write_text("resources\n", encoding="utf-8")
|
||||
(helper_dir / "sites.cpython-312-x86_64-linux-gnu.so").write_text("plugin\n", encoding="utf-8")
|
||||
(resource_dir / "user.sites.v3.bin").write_text("resources\n", encoding="utf-8")
|
||||
(resource_dir / "sites.cpython-312-x86_64-linux-gnu.so").write_text("plugin\n", encoding="utf-8")
|
||||
(public_dir / "index.html").write_text("<!doctype html>\n", encoding="utf-8")
|
||||
(home_dir / ".cloakbrowser" / "chrome").write_text("browser cache\n", encoding="utf-8")
|
||||
(home_dir / "runtime" / "state").write_text("state\n", encoding="utf-8")
|
||||
@@ -64,7 +64,7 @@ def _run_permission_case(tmp_path: Path, body: str, env: dict[str, str] | None =
|
||||
"APP_DIR": str(app_dir),
|
||||
"PUBLIC_DIR": str(public_dir),
|
||||
"HOME_DIR": str(home_dir),
|
||||
"IMAGE_HELPER_DIR": str(helper_dir),
|
||||
"IMAGE_RESOURCE_DIR": str(resource_dir),
|
||||
"CONFIG_DIR": str(tmp_path / "config"),
|
||||
"PUID": str(os.getuid()),
|
||||
"PGID": str(os.getgid()),
|
||||
@@ -192,20 +192,20 @@ def test_runtime_writable_paths_are_still_corrected(tmp_path: Path) -> None:
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/home/runtime" in lines
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/config /var/lib/nginx /var/log/nginx" in lines
|
||||
assert "moviepilot:moviepilot /etc/hosts /tmp" in lines
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/app/app/helper" in lines
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/app/app/infrastructure" in lines
|
||||
assert not any(line.startswith("-R ") and ".cloakbrowser" in line for line in lines)
|
||||
assert not any(f"{tmp_path}/app " in line for line in lines)
|
||||
assert not any(f"{tmp_path}/public" in line for line in lines)
|
||||
|
||||
|
||||
def test_helper_resource_permissions_are_repaired_even_when_owner_matches(tmp_path: Path) -> None:
|
||||
def test_site_resource_permissions_are_repaired_even_when_owner_matches(tmp_path: Path) -> None:
|
||||
log = _run_permission_case(
|
||||
tmp_path,
|
||||
'correct_helper_resource_permissions',
|
||||
'correct_site_resource_permissions',
|
||||
)
|
||||
|
||||
lines = log.splitlines()
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/app/app/helper" in lines
|
||||
assert f"-R moviepilot:moviepilot {tmp_path}/app/app/infrastructure" in lines
|
||||
assert not any(line.startswith("-R ") and f"{tmp_path}/app " in line for line in lines)
|
||||
assert not any(line.startswith("-R ") and f"{tmp_path}/public" in line for line in lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user