oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Oficina ID's signing contract, without reading a profile or Keychain."""
3import importlib.util
4import json
5import os
6from pathlib import Path
7import plistlib
8import tempfile
9from unittest.mock import patch
10
11root = Path(__file__).resolve().parents[1]
12config = json.loads((root / 'mac-updates.json').read_text())
13old_default = '9U4A84C4WK.works.oficina.equipo'
14for relative, group, push in [
15 ('ios/EquipoPhone.entitlements', 'group.works.oficina', 'aps-environment'),
16 ('macos/DeveloperID.entitlements', '9U4A84C4WK.works.oficina', 'com.apple.developer.aps-environment'),
17]:
18 values = plistlib.loads((root / relative).read_bytes())
19 # An unspecified access group still selects the old app-private group.
20 assert values['keychain-access-groups'] == [old_default, '9U4A84C4WK.works.oficina.id'], relative
21 assert values['com.apple.security.application-groups'] == [group], relative
22 assert values['com.apple.developer.associated-domains'] == ['webcredentials:id.oficina.works'], relative
23 assert push in values, relative
24assert config['bundle_id'] == 'works.oficina.equipo'
25
26kit = Path(os.environ.get('OFICINA_NATIVE_PACKAGE_PATH', root / 'apple/.build/checkouts/native'))
27spec = importlib.util.spec_from_file_location('mac_updates', kit / 'tools/mac_updates.py')
28module = importlib.util.module_from_spec(spec)
29spec.loader.exec_module(module)
30# Exercise the bundler used by build-mac.sh, with dummy bytes and mocked
31# signing. Never read the private profile or invoke codesign in this check.
32with tempfile.TemporaryDirectory() as temp:
33 temp = Path(temp)
34 app = temp / 'Equipo.app'
35 (app / 'Contents').mkdir(parents=True)
36 (app / 'Contents/Info.plist').write_bytes(plistlib.dumps({'CFBundleIdentifier': config['bundle_id']}))
37 profile = temp / 'fixture.provisionprofile'
38 profile.write_bytes(b'profile fixture')
39 entitlements = root / config['entitlements']
40 assert module.signing_declaration(None, entitlements, profile, {}) == (entitlements, profile)
41 with patch.object(module, 'decode_profile', return_value={}), \
42 patch.object(module, 'signing_entitlements', return_value=({}, [])), \
43 patch.object(module, 'verify_signature'), patch.object(module.subprocess, 'run'):
44 module.sign_bundle(app, 'fixture identity', entitlements, profile)
45 assert (app / 'Contents/embedded.provisionprofile').read_bytes() == profile.read_bytes()
46 # Ad hoc builds neither open the real profile nor retain restricted grants.
47 with patch.object(module, 'decode_profile', side_effect=AssertionError('opened profile')), \
48 patch.object(module.subprocess, 'run'):
49 granted = module.sign_bundle(app, '-', entitlements, temp / 'absent-profile')
50 assert 'keychain-access-groups' not in granted
51 assert not (app / 'Contents/embedded.provisionprofile').exists()
52print('Oficina ID: old default Keychain group, shared grants and Mac profile embedding checked')
53