Publish APK certificate identity for multi-server compatibility
This commit is contained in:
@@ -22,6 +22,7 @@ class Runner:
|
||||
if command[:2] == ["docker", "run"]:
|
||||
out = Path(command[command.index("-v", command.index("-v") + 1) + 1].split(":")[0])
|
||||
(out / "pipelines.apk").write_bytes(b"apk")
|
||||
(out / "signing-certificate-sha256.txt").write_text("ab" * 32 + "\n")
|
||||
return subprocess.CompletedProcess(command, 0, stdout="", stderr="")
|
||||
|
||||
|
||||
@@ -69,6 +70,36 @@ class AppBuildTests(unittest.TestCase):
|
||||
other = app_build.build("apk", runner=runner, cache=cache, arguments=("--dart-define=X=2",), log=lambda *_: None)
|
||||
self.assertNotEqual(other, first)
|
||||
|
||||
def test_apk_publication_includes_verified_signer_and_file_hash(self):
|
||||
output = Path(self.home.name) / "artifact"
|
||||
output.mkdir()
|
||||
(output / "pipelines.apk").write_bytes(b"verified apk bytes")
|
||||
(output / "signing-certificate-sha256.txt").write_text("AB" * 32 + "\n")
|
||||
(output / ".complete").write_text(json.dumps({"built": 1800000000}))
|
||||
updates = Path(self.home.name) / "updates"
|
||||
manifest = {"web": {"updates": str(updates)}}
|
||||
with patch.object(app_build, "load_manifest", return_value=manifest), patch.object(app_build, "build", return_value=output):
|
||||
app_build.build_apk(Path(self.home.name), server_url="wss://example.com/connect", log=lambda *_: None)
|
||||
feed = json.loads((updates / "version.json").read_text())
|
||||
self.assertEqual(feed["signingCertificateSha256"], "ab" * 32)
|
||||
self.assertEqual(feed["sha256"], app_build.hashlib.sha256((updates / "pipelines.apk").read_bytes()).hexdigest())
|
||||
(output / "signing-certificate-sha256.txt").write_text("invalid")
|
||||
with patch.object(app_build, "load_manifest", return_value=manifest), patch.object(app_build, "build", return_value=output):
|
||||
with self.assertRaisesRegex(ValueError, "exactly one"):
|
||||
app_build.build_apk(Path(self.home.name), server_url="wss://example.com/connect", log=lambda *_: None)
|
||||
self.assertEqual(json.loads((updates / "version.json").read_text()), feed)
|
||||
|
||||
def test_apk_cache_without_signer_metadata_is_rebuilt(self):
|
||||
runner = Runner()
|
||||
cache = Path(self.home.name) / "cache"
|
||||
first = app_build.build("apk", runner=runner, cache=cache, log=lambda *_: None)
|
||||
(first / "signing-certificate-sha256.txt").unlink()
|
||||
runner.calls.clear()
|
||||
rebuilt = app_build.build("apk", runner=runner, cache=cache, log=lambda *_: None)
|
||||
self.assertEqual(rebuilt, first)
|
||||
self.assertTrue(any(c[:2] == ["docker", "run"] for c in runner.calls))
|
||||
self.assertEqual(app_build.apk_signing_fingerprint(rebuilt), "ab" * 32)
|
||||
|
||||
def test_web_build_has_no_build_number(self):
|
||||
runner = Runner()
|
||||
output = app_build.build("web", runner=runner, cache=Path(self.home.name) / "cache", log=lambda *_: None)
|
||||
|
||||
Reference in New Issue
Block a user