feat: support delta update packages
This commit is contained in:
1 parent
7234bf0cac
commit
e315aaf80b
8 files changed
+625
-6
No files matched your search
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
|
||||
|
||||
def test_license_server_api_activates_card(tmp_path):
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -179,6 +181,54 @@ def test_admin_can_publish_update_and_download_installer(tmp_path):
|
||||
assert download.content == payload
|
||||
|
||||
|
||||
def test_admin_can_publish_delta_update_and_download_zip(tmp_path):
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from license_server import api
|
||||
from license_server.core import LicenseService
|
||||
from tests.license_test_keys import TEST_PRIVATE_KEY_PEM
|
||||
|
||||
service = LicenseService(db_path=tmp_path / "license.db", private_key_pem=TEST_PRIVATE_KEY_PEM)
|
||||
client = TestClient(api.create_app(service=service, admin_token="secret"))
|
||||
client.post("/admin/login", data={"admin_token": "secret"}, follow_redirects=False)
|
||||
installer_payload = b"installer bytes"
|
||||
delta_payload = b"zip bytes"
|
||||
|
||||
client.post(
|
||||
"/admin/update/publish",
|
||||
cookies={api.ADMIN_CSRF_COOKIE: "csrf-token"},
|
||||
data={
|
||||
"csrf_token": "csrf-token",
|
||||
"version": "3.3.6",
|
||||
"notes": "smoke",
|
||||
"force": "1",
|
||||
},
|
||||
files={"installer": ("DouyinGuaji-3.3.6-Setup.exe", installer_payload, "application/octet-stream")},
|
||||
)
|
||||
published_delta = client.post(
|
||||
"/admin/update/publish-delta",
|
||||
cookies={api.ADMIN_CSRF_COOKIE: "csrf-token"},
|
||||
data={
|
||||
"csrf_token": "csrf-token",
|
||||
"from_version": "3.3.5",
|
||||
"to_version": "3.3.6",
|
||||
},
|
||||
files={"delta_file": ("DouyinGuaji-3.3.5_to_3.3.6_delta.zip", delta_payload, "application/zip")},
|
||||
)
|
||||
manifest = client.get("/api/v1/update/manifest").json()
|
||||
download = client.get("/api/v1/update/download/DouyinGuaji-3.3.5_to_3.3.6_delta.zip")
|
||||
|
||||
assert published_delta.status_code == 200
|
||||
assert "已发布差量更新 3.3.5 -> 3.3.6" in published_delta.text
|
||||
assert manifest["delta"]["from_version"] == "3.3.5"
|
||||
assert manifest["delta"]["to_version"] == "3.3.6"
|
||||
assert manifest["delta"]["url"].endswith("/api/v1/update/download/DouyinGuaji-3.3.5_to_3.3.6_delta.zip")
|
||||
assert manifest["delta"]["sha256"] == hashlib.sha256(delta_payload).hexdigest()
|
||||
assert isinstance(manifest["signature"], str)
|
||||
assert download.status_code == 200
|
||||
assert download.content == delta_payload
|
||||
|
||||
|
||||
def test_admin_page_shows_stats_cards_and_audit_logs(tmp_path):
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
Reference in new issue
Block a user