Publish curated Unraid-AppOps-Gateway source from 6d175c3333218e2b580a310496fed6c407f28114

This commit is contained in:
Public Source Publisher committed 2026-10-09 12:15:31 +00:00
1 parent 58f5e3c8c2
commit 41fd48f0bc
7 files changed
+339 -16

No files matched your search

+74 -3
View File
@@ -379,9 +379,7 @@ def test_appops_legacy_state_anchor_accepts_only_known_preimage_or_current_green
)
def test_appops_legacy_runtime_requires_pinned_source_image_and_resolved_model(
deploy_module, tmp_path
):
def _fixed_appops_legacy_runtime_case(deploy_module, tmp_path):
project = _project(tmp_path)
project.update({
"branch": "main", "gitea_repository_id": 9,
@@ -435,6 +433,15 @@ def test_appops_legacy_runtime_requires_pinned_source_image_and_resolved_model(
"Config": {"Labels": container["Config"]["Labels"]},
}
return project, container, image
def test_appops_legacy_runtime_requires_pinned_source_image_and_resolved_model(
deploy_module, tmp_path
):
project, container, image = _fixed_appops_legacy_runtime_case(deploy_module, tmp_path)
image_id = deploy_module.APPOPS_LEGACY_OLD_IMAGE_ID
source = "https://gitea.example.com/Jens/Unraid-AppOps-Gateway"
observed = deploy_module.verify_appops_legacy_runtime(project, container, image)
assert observed["imageId"] == image_id
assert observed["imageRef"] == "unraid-appops-gateway:platform-5553c04ce497"
@@ -10604,3 +10611,67 @@ def test_managed_appdata_initializer_http_prerequisite_and_refusal_are_sanitized
server.shutdown()
server.server_close()
serving.join(timeout=2)
@pytest.mark.parametrize("proof", ["signed", "missing", "foreign", "candidate"])
def test_recovery_verifies_restored_container_only_with_signed_live_555_model(
deploy_module, monkeypatch, tmp_path, proof,
):
project, container, image = _fixed_appops_legacy_runtime_case(deploy_module, tmp_path)
container["Id"] = "a" * 64
model_path = "/private/models/signed-555.compose.json"
container["Config"]["Labels"]["com.docker.compose.project.config_files"] = model_path
state = {"live_revision": deploy_module.APPOPS_LEGACY_OLD_REVISION}
active = {"legacy": True, "path": model_path}
if proof == "missing":
active = None
elif proof == "foreign":
active["path"] = "/private/models/foreign.compose.json"
elif proof == "candidate":
active["legacy"] = False
calls = []
def verify_active(actual_state, actual_container, *, project):
calls.append((actual_state, actual_container, project))
return active
reader = types.SimpleNamespace(_self_upgrade_active_compose_model=verify_active)
monkeypatch.setattr(deploy_module, "_appops_status_reader", lambda: reader)
with pytest.raises(deploy_module.DeployError, match="fixed AppOps legacy runtime"):
deploy_module.verify_appops_legacy_runtime(project, container, image)
if proof == "signed":
observed = deploy_module.verify_appops_legacy_runtime(
project, container, image, require_original_container=False, recovery_state=state,
)
assert observed["containerId"] == container["Id"]
else:
with pytest.raises(deploy_module.DeployError):
deploy_module.verify_appops_legacy_runtime(
project, container, image, require_original_container=False, recovery_state=state,
)
assert calls == [(state, container, project)]
@pytest.mark.parametrize("drift", ["image", "ports", "mounts", "health"])
def test_signed_restored_555_proof_preserves_fixed_runtime_checks(
deploy_module, monkeypatch, tmp_path, drift,
):
project, container, image = _fixed_appops_legacy_runtime_case(deploy_module, tmp_path)
container["Id"] = "a" * 64
active = {"legacy": True, "path": "/private/models/signed-555.compose.json"}
monkeypatch.setattr(deploy_module, "_appops_status_reader", lambda: types.SimpleNamespace(
_self_upgrade_active_compose_model=lambda *_a, **_k: active,
))
if drift == "image":
image["Id"] = "sha256:" + "0" * 64
elif drift == "ports":
container["NetworkSettings"]["Ports"]["1216/tcp"][0]["HostIp"] = "127.0.0.1"
elif drift == "mounts":
container["Mounts"][0]["RW"] = False
elif drift == "health":
container["State"]["Health"]["Status"] = "unhealthy"
with pytest.raises(deploy_module.DeployError):
deploy_module.verify_appops_legacy_runtime(
project, container, image, require_original_container=False, recovery_state={},
)