24 lines
909 B
Python
24 lines
909 B
Python
from pathlib import Path
|
|
import unittest
|
|
|
|
from couchd.discovery import AllowlistError, allowlisted_target
|
|
|
|
|
|
class AllowlistTests(unittest.TestCase):
|
|
def test_rejects_target_outside_allowed_roots(self) -> None:
|
|
with self.assertRaises(AllowlistError):
|
|
allowlisted_target(
|
|
candidate=Path("/tmp/SlippiLauncher.AppImage"),
|
|
allowed_roots=[Path("/home/couch/Applications")],
|
|
allowed_names={"SlippiLauncher.AppImage"},
|
|
)
|
|
|
|
def test_accepts_allowed_target_name_under_allowed_root(self) -> None:
|
|
target = allowlisted_target(
|
|
candidate=Path("/home/couch/Applications/SlippiLauncher.AppImage"),
|
|
allowed_roots=[Path("/home/couch/Applications")],
|
|
allowed_names={"SlippiLauncher.AppImage"},
|
|
)
|
|
|
|
self.assertEqual(target, Path("/home/couch/Applications/SlippiLauncher.AppImage"))
|