feat: new configurations for APK/Java/Python/Yum

Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
d9pouces
2026-09-02 06:58:20 +02:00
parent 48ec887808
commit 586f091eeb
22 changed files with 1804 additions and 74 deletions
+25 -11
View File
@@ -21,7 +21,7 @@ def make_context(tmp_path, with_src: bool = True) -> Context:
def test_dst_path_within_destination(tmp_path) -> None:
context = make_context(tmp_path)
resolved = context.dst_path("etc/foo.conf")
assert resolved == context.dst / "etc" / "foo.conf" # nosec B101
assert resolved == context.dst / "etc" / "foo.conf"
def test_dst_path_rejects_escape(tmp_path) -> None:
@@ -32,46 +32,46 @@ def test_dst_path_rejects_escape(tmp_path) -> None:
def test_src_path_without_src(tmp_path) -> None:
context = make_context(tmp_path, with_src=False)
assert context.src_path("etc/foo.conf") is None # nosec B101
assert context.src_path("etc/foo.conf") is None
def test_src_path_with_src(tmp_path) -> None:
context = make_context(tmp_path)
resolved = context.src_path("etc/foo.conf")
assert resolved == context.src / "etc" / "foo.conf" # nosec B101
assert resolved == context.src / "etc" / "foo.conf"
def test_write_file_creates_parents_and_content(tmp_path) -> None:
context = make_context(tmp_path)
path = context.write_file("etc/nested/foo.conf", b"hello")
assert path.read_bytes() == b"hello" # nosec B101
assert path.stat().st_mode & 0o777 == 0o644 # nosec B101
assert path.read_bytes() == b"hello"
assert path.stat().st_mode & 0o777 == 0o644
def test_read_src_file_without_src(tmp_path) -> None:
context = make_context(tmp_path, with_src=False)
assert context.read_src_file("etc/foo.conf") is None # nosec B101
assert context.read_src_file("etc/foo.conf") is None
def test_read_src_file_missing(tmp_path) -> None:
context = make_context(tmp_path)
assert context.read_src_file("etc/missing.conf") is None # nosec B101
assert context.read_src_file("etc/missing.conf") is None
def test_read_src_file_present(tmp_path) -> None:
context = make_context(tmp_path)
(context.src / "foo.conf").write_bytes(b"existing")
assert context.read_src_file("foo.conf") == b"existing" # nosec B101
assert context.read_src_file("foo.conf") == b"existing"
def test_iter_src_dir_without_src(tmp_path) -> None:
context = make_context(tmp_path, with_src=False)
assert context.iter_src_dir("some/dir") == [] # nosec B101
assert context.iter_src_dir("some/dir") == []
def test_iter_src_dir_missing_dir(tmp_path) -> None:
context = make_context(tmp_path)
assert context.iter_src_dir("missing-dir") == [] # nosec B101
assert context.iter_src_dir("missing-dir") == []
def test_iter_src_dir_lists_only_files(tmp_path) -> None:
@@ -82,4 +82,18 @@ def test_iter_src_dir_lists_only_files(tmp_path) -> None:
(target / "b.crt").write_bytes(b"b")
(target / "subdir").mkdir()
result = context.iter_src_dir("certs")
assert [entry.name for entry in result] == ["a.crt", "b.crt"] # nosec B101
assert [entry.name for entry in result] == ["a.crt", "b.crt"]
def test_glob_src_without_src(tmp_path) -> None:
context = make_context(tmp_path, with_src=False)
assert context.glob_src("usr/lib/python3.*") == []
def test_glob_src_matches_pattern(tmp_path) -> None:
context = make_context(tmp_path)
(context.src / "usr/lib/python3.11").mkdir(parents=True)
(context.src / "usr/lib/python3.12").mkdir(parents=True)
(context.src / "usr/lib/python-legacy").mkdir(parents=True)
result = context.glob_src("usr/lib/python3.*")
assert [entry.name for entry in result] == ["python3.11", "python3.12"]