A stable sideload MSIX embedded releases/win32/stable/<bundle> as its MainBundle Uri, an object nothing publishes. Stable promotion points stable.appinstaller at the receipt-bound archive copy, releases/tag/<archive>/<bundle>. Canary was right only because publish_canary_appinstaller keeps its bundle beside the feed. The JS renderer was a second App Installer writer. The header of msix-shared.mjs and the stable-releases guide both give that job to scripts.bundles.release_artifacts. write_embedded_appinstaller now derives both URLs there and calls write_appinstaller. before-build passes it the release facts through HERMES_PYTHON, the same way channelBuildRequest does. The archive is the one the workflow's handoff stage uses: HERMES_ARCHIVE_TAG, else the payload tag. msixBundleName gives stage-msixbundle.mjs and the descriptor one bundle filename. The contract tests check that the embedded bytes match what stable promotion and canary publication write.
79 lines
4.4 KiB
Python
79 lines
4.4 KiB
Python
"""App Installer descriptors bind explicit package facts to explicit feed URLs."""
|
|
import subprocess
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from scripts.bundles import release_artifacts as artifacts
|
|
from tests.scripts.test_release_r2 import r2_server as r2_server # noqa: PLC0414 -- the self-alias is load-bearing: it suppresses F811 for the pytest fixture parameter shadowing this import
|
|
|
|
|
|
@pytest.mark.parametrize('variant', ['bundled', 'light'])
|
|
def test_canary_publication_verifies_native_identity_and_uploads_bundle_before_pointer(tmp_path, r2_server, variant):
|
|
import zipfile
|
|
|
|
tag, version = 'canary.20260902T000000Z-v1.2.4', '1.2.4.1440'
|
|
identity, publisher = f'Fixture.{variant}.Canary', 'CN=Fixture & Team'
|
|
bundle = tmp_path / 'app.msixbundle'
|
|
manifest = ET.Element('Bundle')
|
|
ET.SubElement(manifest, 'Identity', {'Name': identity, 'Publisher': publisher, 'Version': version})
|
|
with zipfile.ZipFile(bundle, 'w') as archive:
|
|
archive.writestr('AppxMetadata/AppxBundleManifest.xml', ET.tostring(manifest))
|
|
base = 'https://releases.example'
|
|
directory = f"releases/win32/{'light/' if variant == 'light' else ''}canary"
|
|
pointer = f'{directory}/canary.appinstaller'
|
|
args = ['publish-appinstaller', '--root', str(tmp_path), '--tag', tag, '--variant', variant,
|
|
'--bundle', str(bundle), '--identity', identity, '--publisher', publisher, '--version', version,
|
|
'--public-base', base]
|
|
artifacts.main(args)
|
|
assert r2_server.store[f'{directory}/{bundle.name}'][0] == bundle.read_bytes()
|
|
descriptor = ET.fromstring(r2_server.store[pointer][0])
|
|
assert descriptor.attrib == {'Uri': f'{base}/{pointer}', 'Version': version}
|
|
assert descriptor.find('{*}MainBundle').attrib == {
|
|
'Name': identity, 'Publisher': publisher, 'Version': version, 'Uri': f'{base}/{directory}/{bundle.name}',
|
|
}
|
|
requests = [(method, path.rsplit('/', 1)[-1]) for method, path, _ in r2_server.requests]
|
|
assert requests.index(('HEAD', bundle.name)) < requests.index(('PUT', 'canary.appinstaller'))
|
|
previous = r2_server.store[pointer]
|
|
for option, bad in [('--identity', 'Wrong'), ('--publisher', 'CN=Wrong'), ('--version', '9.9.9.0'),
|
|
('--tag', 'v1.2.4'), ('--tag', 'a' * 40), ('--variant', 'store')]:
|
|
invalid = list(args)
|
|
invalid[invalid.index(option) + 1] = bad
|
|
r2_server.requests.clear()
|
|
with pytest.raises((ValueError, SystemExit)):
|
|
artifacts.main(invalid)
|
|
assert not r2_server.requests
|
|
assert r2_server.store[pointer] == previous
|
|
|
|
# Fail a real immutable upload by occupying its name with different bytes.
|
|
r2_server.store[f'{directory}/{bundle.name}'] = (b'other bundle', 'application/msixbundle')
|
|
r2_server.requests.clear()
|
|
with pytest.raises(ValueError, match='checksum mismatch'):
|
|
artifacts.main(args)
|
|
assert not any(method == 'PUT' and path.endswith('canary.appinstaller')
|
|
for method, path, _ in r2_server.requests)
|
|
assert r2_server.store[pointer] == previous
|
|
|
|
|
|
def test_embedded_descriptor_is_the_canary_feed_publication_writes(tmp_path, r2_server):
|
|
"""A sideload canary MSIX embeds (uap13:AutoUpdate) the descriptor its canary publication writes."""
|
|
import zipfile
|
|
|
|
tag, version = 'canary.20260902T000000Z-v1.2.4', '1.2.4.1440'
|
|
identity, publisher = 'Fixture.Bundled.Canary', 'CN=Fixture & Team'
|
|
bundle = tmp_path / 'Fixture-1.2.4.1440-win.msixbundle'
|
|
manifest = ET.Element('Bundle')
|
|
ET.SubElement(manifest, 'Identity', {'Name': identity, 'Publisher': publisher, 'Version': version})
|
|
with zipfile.ZipFile(bundle, 'w') as archive:
|
|
archive.writestr('AppxMetadata/AppxBundleManifest.xml', ET.tostring(manifest))
|
|
base = 'https://releases.example'
|
|
artifacts.main(['publish-appinstaller', '--root', str(tmp_path / 'publish'), '--tag', tag, '--variant', 'bundled',
|
|
'--bundle', str(bundle), '--identity', identity, '--publisher', publisher, '--version', version,
|
|
'--public-base', base])
|
|
embedded = tmp_path / 'Update.appinstaller'
|
|
artifacts.write_embedded_appinstaller(embedded, tag=tag, archive=tag, bundle=bundle.name, identity=identity,
|
|
publisher=publisher, version=version, public_base=base)
|
|
assert embedded.read_bytes() == r2_server.store['releases/win32/canary/canary.appinstaller'][0]
|