Files
WoW-Hybrid-gateway/tests/windows_original_control_package_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

45 lines
3.7 KiB
Python

"""One changed-parent boundary: accepted COW custody and pre-write refusals."""
import copy,hashlib,json,tempfile,unittest
from pathlib import Path
import linux_client_package as policy
from windows_client_package import copy_public_client
def sha(path):return hashlib.sha256(path.read_bytes()).hexdigest()
def save(path,value):path.write_text(json.dumps(value))
class OriginalControlParent(unittest.TestCase):
def test_pinned_same_root_copy_and_refusals(self):
with tempfile.TemporaryDirectory() as tmp:
top=Path(tmp);bundle=top/'accepted';base=bundle/'runtime/native-client';game=base/'_classic_beta_'
(game/'WTF').mkdir(parents=True);(game/'WTF/Config.wtf').write_text('SET accountName "PRIVATE"\nSET gxApi "D3D11"\n')
for name in policy.PRODUCT_FILES:(base/name).write_bytes(b'accepted product')
for name in policy.DATA_TREES:
folder=base/'Data'/name;folder.mkdir(parents=True);(folder/'immutable').write_bytes(b'accepted asset')
(base/'Data/data/shmem').write_bytes(b'cache')
for name in policy.GAME_FILES:(game/name).write_bytes(b'accepted game')
for name in policy.GAME_TREES:
(game/name).mkdir();(game/name/'resource').write_bytes(b'resource')
(base/'warrior-action-bar-casc.json').write_text('parent marker')
receipt=top/'publication.json';save(receipt,{'published_build_info_sha256':sha(base/'.build.info')})
root='2ed14fe112a8f061e07eabc80b2ac128'
release=bundle/'windows-release.json';save(release,{'internal_startup_candidate':True,'private_asset_publication':{'receipt_path':str(receipt),'composed_root':root,'registered_assets':23139}})
proof=top/'installed.json';saved_proof={'status':'PASS_COMBINED_INSTALLED_WINDOWS_R18_R19_84026_23139_BOUNDARY','target':str(bundle),'composed_root':root,'registered_assets':23139,'windows_release_sha256':sha(release)};save(proof,saved_proof)
good={'kind':'reviewed-original-nohybrid-control-same-root-v1','required_parent_ROOT':root,'new_ROOT':root,'registered_assets':23139,'files':[],'installed_boundary':str(proof),'installed_boundary_sha256':sha(proof),'publication_receipt_sha256':sha(receipt)}
plan=top/'plan.json';save(plan,good);target=top/'control';copy_public_client(base,target,base,plan)
self.assertEqual((target/'Data/data/immutable').stat().st_ino,(base/'Data/data/immutable').stat().st_ino)
self.assertNotEqual((target/'Data/data/shmem').stat().st_ino,(base/'Data/data/shmem').stat().st_ino)
self.assertNotEqual((target/'_classic_beta_/WowB.exe').stat().st_ino,(game/'WowB.exe').stat().st_ino)
self.assertNotIn('PRIVATE',(target/'_classic_beta_/WTF/Config.wtf').read_text())
self.assertFalse((target/'_classic_beta_/Interface').exists());self.assertFalse((target/'warrior-action-bar-casc.json').exists())
refusals=[{'new_ROOT':'0'*32},{'required_parent_ROOT':'1'*32},{'registered_assets':23138},{'files':[{'relative_path':'Data/data/immutable'}]},{'installed_boundary_sha256':'0'*64},{'publication_receipt_sha256':'0'*64}]
for number,change in enumerate(refusals):
with self.subTest(change=change):
bad=dict(good,**change);save(plan,bad);out=top/f'refused-{number}'
with self.assertRaises(ValueError):copy_public_client(base,out,base,plan)
self.assertFalse(out.exists())
changed=copy.deepcopy(saved_proof);changed['target']=str(top/'other');save(proof,changed);save(plan,dict(good,installed_boundary_sha256=sha(proof)))
with self.assertRaises(ValueError):copy_public_client(base,top/'wrong-owner',base,plan)
save(proof,saved_proof);save(plan,good);(base/'.build.info').write_bytes(b'changed build')
with self.assertRaises(ValueError):copy_public_client(base,top/'wrong-build',base,plan)
self.assertFalse((top/'wrong-owner').exists());self.assertFalse((top/'wrong-build').exists())
if __name__=='__main__':unittest.main()