okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1"""The signed feed and its checks: a bad signature, a bad hash and a downgrade are all refused, and the choice of engine package 2follows the hardware. No network and no engine here (the end-to-end flow is test_updater.py).""" 3 4import base64 5import datetime as dt 6import json 7import os 8import tempfile 9import unittest 10from pathlib import Path 11from unittest import mock 12 13from strata_control import feed as feedmod ,signing ,transfer 14from tests .terminal import update_fixture as fx 15 16SEED1 = bytes .fromhex ("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" ) 17PUB1 = bytes .fromhex ("d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a" ) 18SIG1 = bytes .fromhex ("e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b" ) 19SEED2 = bytes .fromhex ("4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb" ) 20PUB2 = bytes .fromhex ("3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c" ) 21SIG2 = bytes .fromhex ("92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00" ) 22 23 24class Ed25519 (unittest .TestCase ): 25def test_rfc8032_vectors (self ): 26self .assertEqual (signing .public_from_seed (SEED1 ),PUB1 ) 27self .assertEqual (signing .sign_raw (SEED1 ,b"" ),SIG1 ) 28self .assertTrue (signing .verify_raw (PUB1 ,b"" ,SIG1 )) 29self .assertEqual (signing .public_from_seed (SEED2 ),PUB2 ) 30self .assertEqual (signing .sign_raw (SEED2 ,b"\x72" ),SIG2 ) 31self .assertTrue (signing .verify_raw (PUB2 ,b"\x72" ,SIG2 )) 32 33def test_tampering_is_refused (self ): 34self .assertFalse (signing .verify_raw (PUB2 ,b"\x73" ,SIG2 )) 35self .assertFalse (signing .verify_raw (PUB1 ,b"\x72" ,SIG2 )) 36bad = bytearray (SIG2 ) 37bad [10 ]^= 1 38self .assertFalse (signing .verify_raw (PUB2 ,b"\x72" ,bytes (bad ))) 39self .assertFalse (signing .verify_raw (PUB2 ,b"\x72" ,SIG2 [:63 ])) 40high_s = SIG2 [:32 ]+ (int .from_bytes (SIG2 [32 :],"little" )+ signing ._L ).to_bytes (32 ,"little" ) 41self .assertFalse (signing .verify_raw (PUB2 ,b"\x72" ,high_s ),"a non-canonical s must be refused" ) 42 43def test_documents_and_key_ids (self ): 44key = signing .generate_key () 45trusted = fx .trusted_of (key ) 46signature = signing .sign_bytes (key ,b"hello" ) 47self .assertEqual (signing .verify_bytes (trusted ,b"hello" ,signature ),key ["key_id" ]) 48with self .assertRaises (signing .SignatureError ): 49signing .verify_bytes (trusted ,b"hellO" ,signature ) 50other = signing .generate_key () 51with self .assertRaisesRegex (signing .SignatureError ,"does not trust" ): 52signing .verify_bytes (fx .trusted_of (other ),b"hello" ,signature ) 53entry = signing .public_part (key ) 54entry ["key_id" ]= "0" * 16 55with self .assertRaises (signing .SignatureError ): 56signing .parse_public (entry ) 57 58def test_minisign_app_signature (self ): 59public ,secret = fx .minisign_pair () 60blob = os .urandom (5000 ) 61sig = fx .minisign_sign (blob ,secret ) 62signing .minisign_verify (public ,sig , [blob [:1000 ],blob [1000 :]]) 63with self .assertRaises (signing .SignatureError ): 64signing .minisign_verify (public ,sig , [blob + b"x" ]) 65other_public ,_ = fx .minisign_pair () 66with self .assertRaisesRegex (signing .SignatureError ,"different key" ): 67signing .minisign_verify (other_public ,sig , [blob ]) 68text = base64 .b64decode (sig ).decode ().replace ("timestamp:1" ,"timestamp:2" ) 69with self .assertRaisesRegex (signing .SignatureError ,"comment was changed" ): 70signing .minisign_verify (public ,base64 .b64encode (text .encode ()).decode (), [blob ]) 71 72 73def entry (version = "0.1.46" ,backend = "cuda" ,variant = "cuda13" ,archs = ("sm_86" ,"compute_89" ),driver = "580.65" ,** extra ): 74base = {"version" :version ,"platform" :"linux-x86_64" ,"backend" :backend ,"variant" :variant ,"archs" :list (archs ), 75"min_driver" : {"nvidia" :driver }if backend == "cuda" else {},"min_runtime" :None ,"build_id" :f"b- { version } - { variant } " , 76"format" :"tar.gz" ,"url" :f"engine/e- { version } - { variant } .tar.gz" ,"size" :1000 ,"sha256" :"a" * 64 , 77"manifest_sha256" :"b" * 64 ,"installed_bytes" :2000 ,"notes" :"" } 78base .update (extra ) 79return base 80 81 82def document (** over ): 83doc = {"schema_version" :1 ,"feed" :"strata-updates" ,"channel" :"stable" ,"sequence" :5 , 84"generated_at" :"2026-10-15T00:00:00Z" ,"expires_at" :None ,"engine" : {"packages" : [entry ()]}} 85doc .update (over ) 86return doc 87 88 89def signed (doc ,key ): 90payload = (json .dumps (doc ,indent = 1 ,sort_keys = True )+ "\n" ).encode () 91return payload ,json .dumps (signing .sign_bytes (key ,payload )).encode () 92 93 94class FeedChecks (unittest .TestCase ): 95def setUp (self ): 96self .key = signing .generate_key () 97self .trusted = fx .trusted_of (self .key ) 98 99def load (self ,payload ,sig ,** guards ): 100return feedmod .verify_and_parse (payload ,sig ,source = "/feeds/strata-feed.json" ,trusted = self .trusted ,** guards ) 101 102def test_a_good_feed_loads (self ): 103feed = self .load (* signed (document (),self .key )) 104self .assertEqual ((feed .sequence ,feed .channel ,feed .key_id ), (5 ,"stable" ,self .key ["key_id" ])) 105self .assertEqual (feed .engine [0 ].label ,"0.1.46 linux-x86_64-cuda-cuda13" ) 106 107def test_a_bad_signature_is_refused (self ): 108payload ,sig = signed (document (),self .key ) 109forged = json .loads (sig ) 110raw = bytearray (base64 .b64decode (forged ["value" ])) 111raw [3 ]^= 0x40 112forged ["value" ]= base64 .b64encode (bytes (raw )).decode () 113with self .assertRaisesRegex (feedmod .FeedError ,"not trusted" ): 114self .load (payload ,json .dumps (forged ).encode ()) 115 116def test_a_feed_changed_after_signing_is_refused (self ): 117payload ,sig = signed (document (),self .key ) 118with self .assertRaisesRegex (feedmod .FeedError ,"does not match the signed content" ): 119self .load (payload .replace (b'"sequence": 5' ,b'"sequence": 6' ),sig ) 120 121def test_a_feed_signed_by_an_unknown_key_is_refused (self ): 122payload ,sig = signed (document (),signing .generate_key ()) 123with self .assertRaisesRegex (feedmod .FeedError ,"does not trust" ): 124self .load (payload ,sig ) 125 126def test_no_trusted_keys_means_no_update (self ): 127payload ,sig = signed (document (),self .key ) 128with self .assertRaisesRegex (feedmod .FeedError ,"trusts no update key" ): 129feedmod .verify_and_parse (payload ,sig ,source = "x/strata-feed.json" ,trusted = {}) 130 131def test_an_older_feed_is_a_downgrade (self ): 132payload ,sig = signed (document (sequence = 4 ),self .key ) 133with self .assertRaises (feedmod .FeedDowngrade ): 134self .load (payload ,sig ,last_sequence = 5 ) 135self .assertEqual (self .load (* signed (document (sequence = 5 ),self .key ),last_sequence = 5 ).sequence ,5 ) 136self .assertEqual (self .load (* signed (document (sequence = 9 ),self .key ),last_sequence = 5 ).sequence ,9 ) 137 138def test_an_expired_feed_and_another_channel_are_refused (self ): 139payload ,sig = signed (document (expires_at = "2026-01-01T00:00:00Z" ),self .key ) 140with self .assertRaisesRegex (feedmod .FeedError ,"expired" ): 141self .load (payload ,sig ,now = dt .datetime (2026 ,10 ,15 ,tzinfo = dt .timezone .utc )) 142with self .assertRaisesRegex (feedmod .FeedError ,"channel" ): 143self .load (* signed (document (channel = "beta" ),self .key ),channel = "stable" ) 144 145def test_malformed_entries_are_errors_not_defaults (self ): 146for change in ({"sha256" :"nothex" }, {"size" :0 }, {"version" :"latest" }, {"archs" : []}, {"manifest_sha256" :None }, {"size" :True }): 147with self .subTest (change = change ): 148with self .assertRaises (feedmod .FeedError ): 149self .load (* signed (document (engine = {"packages" : [entry (** change )]}),self .key )) 150for change in ({"format" :"rar" }, {"platform" :"plan9" }, {"backend" :"tpu" }):# a kind this Control does not know: left out with a line, not an error (0.1.53) 151with self .subTest (unknown = change ): 152feed = self .load (* signed (document (engine = {"packages" : [entry (),entry (** change ,url = "other.tar.gz" )]}),self .key )) 153self .assertEqual (len (feed .engine ),1 ) 154self .assertEqual (len (feed .skipped ),1 ) 155with self .assertRaisesRegex (feedmod .FeedError ,"twice" ): 156self .load (* signed (document (engine = {"packages" : [entry (),entry ()]}),self .key )) 157with self .assertRaises (feedmod .FeedError ): 158self .load (b"not json" ,signed (document (),self .key )[1 ]) 159 160def test_versions_are_strict_and_ordered (self ): 161self .assertLess (feedmod .version_key ("0.1.9" ),feedmod .version_key ("0.1.10" )) 162self .assertLess (feedmod .version_key ("0.1.45" ),feedmod .version_key ("0.1.45.1" )) 163with self .assertRaises (feedmod .FeedError ): 164feedmod .version_key ("0.1.x" ) 165 166 167class Selection (unittest .TestCase ): 168HW = {"platform" :"linux-x86_64" ,"backend" :"cuda" ,"runtime" :"0.1.45" ,"nvidia_driver" :"615.71" ,"cuda_archs" : ["sm_86" ],"gfx" : []} 169 170def pick (self ,packages ,** hw ): 171parsed = [feedmod ._engine_package (p )for p in packages ] 172return feedmod .select_engine (parsed , {** self .HW ,** hw }) 173 174def test_cuda_13_when_the_driver_is_new_enough_else_12 (self ): 175both = [entry (variant = "cuda12" ,driver = "575.51" ,archs = ("sm_60" ,"sm_86" ,"compute_89" )),entry (variant = "cuda13" )] 176self .assertEqual (self .pick (both )[0 ].variant ,"cuda13" ) 177old = self .pick (both ,nvidia_driver = "576.02" ) 178self .assertEqual (old [0 ].variant ,"cuda12" ) 179self .assertTrue (any ("580.65" in r for r in old [1 ])) 180self .assertIsNone (self .pick (both ,nvidia_driver = "500.00" )[0 ]) 181 182def test_an_update_keeps_the_cuda_build_that_runs_here (self ):# #3835 183both = [entry (variant = "cuda12" ,driver = "575.51" ,archs = ("sm_60" ,"sm_61" ,"sm_86" ,"compute_89" )),entry (variant = "cuda13" )] 184two_cards = {"cuda_archs" : ["sm_61" ,"sm_86" ],"nvidia_driver" :"615.71" } 185self .assertEqual (self .pick (both ,** two_cards )[0 ].variant ,"cuda13" )# nothing installed: as before 186kept ,reasons = self .pick (both ,installed_variant = "cuda12" ,** two_cards ) 187self .assertEqual (kept .variant ,"cuda12" ) 188self .assertTrue (any ("is kept" in r for r in reasons )) 189only13 = [entry (variant = "cuda13" )] 190self .assertEqual (self .pick (only13 ,installed_variant = "cuda12" )[0 ].variant ,"cuda13" )# the feed has no 12: the best fit 191 192def test_the_newest_version_wins_and_the_card_must_be_covered (self ): 193newer = [entry ("0.1.45" ),entry ("0.1.46" )] 194self .assertEqual (self .pick (newer )[0 ].version ,"0.1.46" ) 195pascal = self .pick ([entry (archs = ("sm_75" ,"sm_86" ,"compute_86" ))],cuda_archs = ["sm_61" ]) 196self .assertIsNone (pascal [0 ]) 197self .assertIn ("this PC's GPU is sm_61" ,pascal [1 ][0 ]) 198self .assertIsNotNone (self .pick ([entry (archs = ("sm_75" ,"compute_75" ))],cuda_archs = ["sm_120" ])[0 ],"PTX covers a newer card" ) 199 200def test_hip_by_gfx_sycl_and_metal_by_platform (self ): 201hip = [entry (backend = "hip" ,variant = "" ,archs = ("gfx1200" ,"gfx1201" ))] 202self .assertIsNotNone (self .pick (hip ,backend = "hip" ,gfx = ["gfx1201" ])[0 ]) 203self .assertIsNone (self .pick (hip ,backend = "hip" ,gfx = ["gfx1100" ])[0 ]) 204self .assertIsNotNone (self .pick (hip ,backend = "hip" ,gfx = [])[0 ],"an unreadable gfx is not a refusal" ) 205self .assertIsNone (self .pick (hip ,backend = "cuda" )[0 ],"a HIP package is not offered to an NVIDIA PC" ) 206sycl = [entry (backend = "sycl" ,variant = "" ,archs = ("intel-arc" ,))] 207self .assertIsNotNone (self .pick (sycl ,backend = "sycl" )[0 ]) 208metal = dict (entry (backend = "metal" ,variant = "" ,archs = ("apple-gpu" ,)),platform = "macos-arm64" ) 209self .assertIsNone (self .pick ([metal ])[0 ],"wrong platform" ) 210self .assertIsNotNone (self .pick ([metal ],platform = "macos-arm64" ,backend = "metal" )[0 ]) 211 212def test_min_runtime (self ): 213got = self .pick ([entry (min_runtime = "0.1.50" )]) 214self .assertIsNone (got [0 ]) 215self .assertIn ("needs control 0.1.50" ,got [1 ][0 ]) 216 217 218class References (unittest .TestCase ): 219def test_references_stay_inside_the_feed (self ): 220base = "http://127.0.0.1:9/feed/" 221self .assertEqual (transfer .resolve_ref (base ,"engine/a.tar.gz" ),"http://127.0.0.1:9/feed/engine/a.tar.gz" ) 222for bad in ("../x" ,"/etc/passwd" ,"a/../../b" ,"file:///etc/passwd" ,"ftp://example.com/x" ,"a\\b" ,"http://example.com/x" ): 223with self .subTest (bad = bad ),self .assertRaises (transfer .TransferError ): 224transfer .resolve_ref (base ,bad ) 225self .assertEqual (transfer .resolve_ref ("https://example.com/f/" ,"https://cdn.example.com/x" ),"https://cdn.example.com/x" ) 226 227def test_a_local_feed_cannot_name_a_remote_address (self ): 228with tempfile .TemporaryDirectory ()as folder : 229with self .assertRaises (transfer .TransferError ): 230transfer .resolve_ref (folder ,"https://evil.example.com/x" ) 231with self .assertRaises (transfer .TransferError ): 232transfer .resolve_ref (folder ,"../outside" ) 233self .assertTrue (transfer .resolve_ref (folder ,"engine/a" ).startswith (str (Path (folder ).resolve ()))) 234 235 236class Downloads (unittest .TestCase ): 237def test_a_partial_file_resumes_and_a_bad_hash_is_deleted (self ): 238import hashlib 239with tempfile .TemporaryDirectory ()as folder : 240data = os .urandom (300_000 ) 241source = Path (folder )/ "a.bin" 242source .write_bytes (data ) 243partial = Path (folder )/ "x.part" 244partial .write_bytes (data [:100_000 ]) 245seen = [] 246done = transfer .download (str (source ),partial ,size = len (data ),sha256 = hashlib .sha256 (data ).hexdigest (), 247progress = lambda d ,t :seen .append (d )) 248self .assertEqual (done .read_bytes (),data ) 249self .assertEqual (seen [0 ]> 100_000 ,True ,"it continued from the partial file instead of starting over" ) 250partial .write_bytes (data [:50_000 ]) 251with self .assertRaises (transfer .ChecksumMismatch ): 252transfer .download (str (source ),partial ,size = len (data ),sha256 = "0" * 64 ) 253self .assertFalse (partial .exists (),"bytes that fail the signed hash are not kept" ) 254partial .write_bytes (b"x" * (len (data )+ 5 )) 255transfer .download (str (source ),partial ,size = len (data ),sha256 = hashlib .sha256 (data ).hexdigest ()) 256self .assertEqual (partial .read_bytes (),data ,"an oversized stale partial is discarded, not appended to" ) 257 258 259class FeedTool (unittest .TestCase ): 260"""The owner's release tool: keys are made outside git, never printed, never overwritten; what it writes verifies.""" 261 262def test_keygen_refuses_a_git_checkout_and_an_existing_key_and_never_prints_the_secret (self ): 263import contextlib 264import io 265from feed_tool import keygen ,main 266with tempfile .TemporaryDirectory ()as folder : 267repo = Path (folder )/ "checkout" 268 (repo / ".git" ).mkdir (parents = True ) 269with self .assertRaises (SystemExit ): 270keygen (repo / "keys" ) 271keys = Path (folder )/ "keys" 272out = io .StringIO () 273with contextlib .redirect_stdout (out ): 274main (["keygen" ,"--out" ,str (keys )]) 275secret = json .loads ((keys / "feed-key.json" ).read_text ()) 276self .assertNotIn (secret ["seed" ],out .getvalue ()) 277self .assertIn (secret ["key_id" ],out .getvalue ()) 278public = json .loads ((keys / "feed-key.pub.json" ).read_text ()) 279self .assertNotIn ("seed" ,json .dumps (public )) 280self .assertEqual (public ["keys" ][0 ]["key_id" ],secret ["key_id" ]) 281with self .assertRaises (SystemExit ): 282keygen (keys ) 283if os .name != "nt" : 284self .assertEqual ((keys / "feed-key.json" ).stat ().st_mode & 0o077 ,0 ,"the secret is readable by its owner only" ) 285self .assertTrue (json .loads ((keys / "feed-key.json" ).read_text ())["seed" ]) 286 287def test_a_feed_the_tool_writes_verifies_with_the_public_file_and_a_changed_byte_does_not (self ): 288import contextlib 289import io 290from feed_tool import build_feed ,keygen ,main 291with tempfile .TemporaryDirectory ()as folder : 292keygen (Path (folder )/ "keys" ) 293key = json .loads ((Path (folder )/ "keys" / "feed-key.json" ).read_text ()) 294release = Path (folder )/ "release" 295build_feed (release ,key = key ,sequence = 3 ) 296out = io .StringIO () 297with contextlib .redirect_stdout (out ): 298main (["verify-feed" ,str (release ),"--pub" ,str (Path (folder )/ "keys" / "feed-key.pub.json" )]) 299self .assertIn ("sequence 3" ,out .getvalue ()) 300feed = release / "strata-feed.json" 301feed .write_bytes (feed .read_bytes ().replace (b'"sequence": 3' ,b'"sequence": 4' )) 302with self .assertRaises (feedmod .FeedError ): 303main (["verify-feed" ,str (release ),"--pub" ,str (Path (folder )/ "keys" / "feed-key.pub.json" )]) 304 305 306class DeepSeekEnginePackages (FeedChecks ): 307"""The ``dsv41`` feed member stays in the feed, frozen, for Strata 0.2.13 and earlier (their DeepSeek engine); this Control runs no 308DeepSeek model and does not read it (strata_control/retired.py).""" 309 310def test_the_member_is_ignored_and_is_never_an_engine_package (self ): 311ds = entry (version = "0.1.49" ,variant = "cuda13" ,url = "dsv41/strata-dsv41-0.1.49-linux-x86_64-cuda-cuda13.tar.gz" ) 312feed = self .load (* signed (document (dsv41 = {"packages" : [ds ]}),self .key )) 313self .assertFalse (hasattr (feed ,"dsv41" )) 314self .assertEqual ([p .version for p in feed .engine ], ["0.1.46" ],"a DeepSeek package is not an engine package" ) 315self .assertEqual (feed .skipped , ()) 316 317class AppPlatform (unittest .TestCase ): 318"""`feed_tool.py set-app-platform`: the signed Mac archive goes into the Tauri updater json, and only if it verifies.""" 319 320def setUp (self ): 321import io 322import tarfile 323self .temp = tempfile .TemporaryDirectory () 324self .addCleanup (self .temp .cleanup ) 325self .root = Path (self .temp .name ) 326self .public ,self .secret = fx .minisign_pair () 327self .archive = self .root / "Strata.app.tar.gz" 328with tarfile .open (self .archive ,"w:gz" )as tar : 329for name ,data in (("Strata.app/Contents/Info.plist" ,b"<plist/>" ), ("Strata.app/Contents/MacOS/strata-desktop" ,b"bin" )): 330info = tarfile .TarInfo (name ) 331info .size = len (data ) 332tar .addfile (info ,io .BytesIO (data )) 333self .sig = self .root / "Strata.app.tar.gz.sig" 334self .sig .write_text (fx .minisign_sign (self .archive .read_bytes (),self .secret )+ "\n" ) 335self .app_json = self .root / "latest.json" 336 337def run_tool (self ,** extra ): 338from feed_tool import set_app_platform 339args = dict (target = "darwin-aarch64" ,archive = self .archive ,signature_file = self .sig ,url = "https://example.invalid/Strata.app.tar.gz" , 340version = "0.2.0" ,pubkey = self .public ) 341args .update (extra ) 342return set_app_platform (self .app_json ,** args ) 343 344def test_a_signed_mac_archive_is_added_with_its_hash_and_size (self ): 345import hashlib 346entry = self .run_tool () 347document = json .loads (self .app_json .read_text ()) 348self .assertEqual (document ["version" ],"0.2.0" ) 349self .assertEqual (document ["platforms" ]["darwin-aarch64" ],entry ) 350self .assertEqual (entry ["sha256" ],hashlib .sha256 (self .archive .read_bytes ()).hexdigest ()) 351self .assertEqual (entry ["size" ],self .archive .stat ().st_size ) 352self .assertEqual (entry ["signature" ],self .sig .read_text ().strip ()) 353 354def test_the_result_is_a_feed_app_member_control_accepts (self ): 355from feed_tool import build_feed ,keygen 356self .run_tool () 357keygen (self .root / "keys" ) 358key = json .loads ((self .root / "keys" / "feed-key.json" ).read_text ()) 359document = build_feed (self .root / "release" ,key = key ,sequence = 1 ,app_json = self .app_json ) 360self .assertIn ("darwin-aarch64" ,document ["app" ]["platforms" ]) 361self .assertTrue ((self .root / "release" / "app" / "latest.json" ).exists ()) 362 363def test_a_second_platform_is_added_beside_the_first (self ): 364self .run_tool () 365self .run_tool (target = "windows-x86_64" ) 366self .assertEqual (sorted (json .loads (self .app_json .read_text ())["platforms" ]), ["darwin-aarch64" ,"windows-x86_64" ]) 367 368def test_a_signature_of_a_different_file_is_refused_and_nothing_is_written (self ): 369"""What `tauri build` left behind (the unsigned app) signs different bytes than the notarised archive we upload.""" 370self .archive .write_bytes (self .archive .read_bytes ()+ b"x" ) 371with self .assertRaises (SystemExit )as caught : 372self .run_tool () 373self .assertIn ("does not verify" ,str (caught .exception )) 374self .assertFalse (self .app_json .exists ()) 375 376def test_a_signature_from_another_key_is_refused (self ): 377other_public ,_ = fx .minisign_pair () 378with self .assertRaises (SystemExit ): 379self .run_tool (pubkey = other_public ) 380 381def test_a_mac_archive_must_hold_the_app_at_its_root (self ): 382import io 383import tarfile 384with tarfile .open (self .archive ,"w:gz" )as tar : 385info = tarfile .TarInfo ("build/Strata.app/Contents/Info.plist" ) 386info .size = 1 387tar .addfile (info ,io .BytesIO (b"x" )) 388self .sig .write_text (fx .minisign_sign (self .archive .read_bytes (),self .secret )) 389with self .assertRaises (SystemExit )as caught : 390self .run_tool () 391self .assertIn ("root" ,str (caught .exception )) 392 393def test_the_default_key_is_the_one_in_tauri_conf (self ): 394from feed_tool import _default_app_pubkey 395self .assertEqual (_default_app_pubkey (),json .loads ((fx .ROOT / "apps/desktop/src-tauri/tauri.conf.json" ).read_text ())["plugins" ]["updater" ]["pubkey" ]) 396 397def test_a_version_mismatch_is_refused (self ): 398self .run_tool () 399with self .assertRaises (SystemExit ): 400self .run_tool (version = "0.2.1" ) 401 402 403if __name__ == "__main__" : 404unittest .main ()