mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: add key_filename support for APK repositories
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -223,6 +223,63 @@ def test_apply_reuses_cached_existing_urls_and_handles_missing_file(tmp_path) ->
|
||||
assert not (dst / "etc/apk/repositories").exists()
|
||||
|
||||
|
||||
def test_apply_uses_key_filename_when_valid(tmp_path) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
"organisation": "InterDiode",
|
||||
"configurations": {
|
||||
"apk": {
|
||||
"repositories": [
|
||||
{
|
||||
"name": "main",
|
||||
"url": "https://example.invalid/v3.19/main",
|
||||
"key": "fake-apk-key-bytes",
|
||||
"key_filename": "main.rsa.pub",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
src = tmp_path / "src"
|
||||
(src / "etc/apk").mkdir(parents=True)
|
||||
dst = tmp_path / "dst"
|
||||
context = Context(config=Configuration.model_validate(data), dst=dst, src=src)
|
||||
|
||||
ApkModule().apply(context)
|
||||
|
||||
key_content = (dst / "etc/apk/keys" / "main.rsa.pub").read_bytes()
|
||||
assert key_content == b"fake-apk-key-bytes"
|
||||
|
||||
|
||||
def test_apply_falls_back_to_derived_name_when_key_filename_invalid(tmp_path) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
"organisation": "InterDiode",
|
||||
"configurations": {
|
||||
"apk": {
|
||||
"repositories": [
|
||||
{
|
||||
"name": "main",
|
||||
"url": "https://example.invalid/v3.19/main",
|
||||
"key": "fake-apk-key-bytes",
|
||||
"key_filename": "../escape",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
src = tmp_path / "src"
|
||||
(src / "etc/apk").mkdir(parents=True)
|
||||
dst = tmp_path / "dst"
|
||||
context = Context(config=Configuration.model_validate(data), dst=dst, src=src)
|
||||
|
||||
ApkModule().apply(context)
|
||||
|
||||
assert not (dst / "etc/apk/keys" / "../escape").exists()
|
||||
key_content = (dst / "etc/apk/keys" / KEY_FILENAME).read_bytes()
|
||||
assert key_content == KEY_BYTES
|
||||
|
||||
|
||||
def test_apply_writes_nothing_when_no_repositories_at_all(tmp_path) -> None:
|
||||
empty_config = Configuration.model_validate(
|
||||
{"uuid": "12345678-1234-5678-1234-567812345678", "organisation": "InterDiode"}
|
||||
|
||||
Reference in New Issue
Block a user