videogen/tests/reelforge/test_desktop_update_signer.py
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

104 lines
2.9 KiB
Python

from __future__ import annotations
import base64
import hashlib
import json
from pathlib import Path
import subprocess
import sys
def test_desktop_update_signer_derives_artifact_truth_and_valid_signature(
tmp_path: Path,
) -> None:
root = Path(__file__).resolve().parents[2]
script = root / "scripts" / "sign-desktop-update.py"
private_key = tmp_path / "release-key.pem"
public_key = tmp_path / "release-public.pem"
artifact = tmp_path / "Menivor-x86_64.AppImage"
artifact.write_bytes(b"real release artifact")
subprocess.run(
["openssl", "genpkey", "-algorithm", "ED25519", "-out", str(private_key)],
check=True,
)
subprocess.run(
[
"openssl",
"pkey",
"-in",
str(private_key),
"-pubout",
"-out",
str(public_key),
],
check=True,
)
spec = {
"channel": "stable",
"version": "1.2.3",
"published_at": "2026-08-28T00:00:00Z",
"notes_url": "https://updates.example/1.2.3",
"artifacts": [
{
"platform": "linux",
"arch": "x86_64",
"kind": "appimage",
"url": "https://updates.example/Menivor-x86_64.AppImage",
"path": str(artifact),
}
],
}
spec_path = tmp_path / "spec.json"
manifest_path = tmp_path / "stable.json"
spec_path.write_text(json.dumps(spec), encoding="utf-8")
completed = subprocess.run(
[
sys.executable,
str(script),
"--spec",
str(spec_path),
"--private-key",
str(private_key),
"--key-id",
"release-1",
"--output",
str(manifest_path),
],
check=True,
capture_output=True,
text=True,
)
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
release = manifest["release"]
assert manifest["schema_version"] == 1
assert manifest["key_id"] == "release-1"
assert release["artifacts"][0]["size_bytes"] == artifact.stat().st_size
assert release["artifacts"][0]["sha256"] == hashlib.sha256(
artifact.read_bytes()
).hexdigest()
assert "MENIVOR_UPDATE_PUBLIC_KEY_BASE64=" in completed.stdout
canonical = json.dumps(
release, ensure_ascii=False, separators=(",", ":")
).encode()
payload_path = tmp_path / "canonical.json"
signature_path = tmp_path / "canonical.sig"
payload_path.write_bytes(canonical)
signature_path.write_bytes(base64.b64decode(manifest["signature_base64"]))
subprocess.run(
[
"openssl",
"pkeyutl",
"-verify",
"-pubin",
"-inkey",
str(public_key),
"-rawin",
"-in",
str(payload_path),
"-sigfile",
str(signature_path),
],
check=True,
)