883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
70 lines
4.3 KiB
Python
70 lines
4.3 KiB
Python
#!/usr/bin/env python3
|
|
"""New model binding/readiness boundary; publication owner is separately tested."""
|
|
import hashlib,json,sys,tempfile
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import native_model_probe as probe
|
|
import published_client_assets as publication
|
|
|
|
MODEL='wowhybrid/source-equipment/'+'a'*64+'.m2'
|
|
|
|
def encoded(path,value):
|
|
data=(json.dumps(value,separators=(',',':'))+'\n').encode();path.write_bytes(data)
|
|
return hashlib.sha256(data).hexdigest()
|
|
|
|
class Controller:
|
|
def __init__(self,closed=0,consumed=True,enabled=True,owner=True):self.calls=[];self.closed=closed;self.consumed=consumed;self.enabled=enabled;self.owner=owner
|
|
def rpc(self,name,**options):
|
|
self.calls.append((name,options))
|
|
if name=='inspect-engine-pipe':return {'error':0,'closed':self.closed,'world_auth':1,'world':{'login_sent':1,'self_create':1}}
|
|
if name=='inspect-engine-session':return {'netclient':{'state_enum':5,'packet_host':{'self_create_consumed':self.consumed}}}
|
|
if name=='inspect-native-channel-policy':return {'enabled':self.enabled,'error':0,'owner_matches':self.owner}
|
|
raise AssertionError('Unexpected RPC')
|
|
class Session:
|
|
def __init__(self,state='loading-or-unknown'):self.observed=0;self.value=state
|
|
def state(self,**options):assert options=={'world_first':True};self.observed+=1;return self.value
|
|
|
|
def main():
|
|
original=publication.published_source
|
|
try:
|
|
with tempfile.TemporaryDirectory() as temporary:
|
|
root=Path(temporary);manifest=root/'assets.json';receipt=root/'receipt.json';release=root/'linux-release.json';proof_calls=[];proof={}
|
|
asset={'file_data_id':8538436,'path':MODEL,'kind':'model','content_key':'b'*32}
|
|
def stage(value):
|
|
digest=encoded(manifest,{'assets':[value]})
|
|
rid=encoded(receipt,{'inputs':{'assets':{'path':str(manifest),'sha256':digest}}})
|
|
encoded(release,{'private_asset_publication':{'receipt_path':str(receipt)}})
|
|
proof.update(receipt_sha256=rid,registered_assets=1,composed_root='c'*32)
|
|
stage(asset)
|
|
def accepted(path):assert path==root;proof_calls.append(path);return proof
|
|
publication.published_source=accepted
|
|
bound=probe.owned_published_model_binding(root,MODEL,8538436)
|
|
assert bound['kind']=='model' and bound['file_data_id']==8538436 and bound['community_listfile_or_named_lookup_claimed'] is False
|
|
for changed in ({**asset,'kind':'texture'},{**asset,'path':MODEL.replace('a'*64,'d'*64)},{**asset,'file_data_id':8538437}):
|
|
stage(changed)
|
|
try:probe.owned_published_model_binding(root,MODEL,8538436)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Wrong typed binding accepted')
|
|
stage(asset);manifest.write_text('{"assets":[]}')
|
|
try:probe.owned_published_model_binding(root,MODEL,8538436)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Changed pinned manifest accepted')
|
|
before=len(proof_calls)
|
|
for path,identity in [('Creature/Wrong.m2',8538436),(MODEL,None),(MODEL,True)]:
|
|
try:probe.owned_published_model_binding(root,path,identity)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Unscoped owned request accepted')
|
|
assert len(proof_calls)==before
|
|
account={'server_proof_verified':1,'transport_prepared':1,'auth_port':3724,'selected_index':0,'realms':[{'address':'127.0.0.1:8090'}]}
|
|
c=Controller();s=Session();ready=probe.require_model_probe_native_world(c,s,account)
|
|
assert s.observed==1 and len(c.calls)==3 and ready['zone_OCR_wait_repeated'] is False
|
|
for controller,session in [(Controller(closed=1),Session()),(Controller(consumed=False),Session()),(Controller(enabled=False),Session()),(Controller(owner=False),Session()),(Controller(),Session('characters'))]:
|
|
try:probe.require_model_probe_native_world(controller,session,account)
|
|
except RuntimeError:pass
|
|
else:raise AssertionError('Unproven input scope accepted')
|
|
assert len(probe.commands('Creature/Control/Control.m2','12345678',123))==4
|
|
print(json.dumps({'status':'PASS','active_publication_pinned_owned_model_binding':True,'wrong_type_path_FDI_and_changed_pin_refused':True,'community_command_scope_unchanged':True,'unknown_zone_requires_live_native_consumed_self_and_owned_policy':True,'known_nonWorld_closed_unconsumed_disabled_wrongowner_refused':True,'native_calls_input_SDK_or_payload_reads':False,'publication_validator_retested':False}))
|
|
finally:publication.published_source=original
|
|
|
|
if __name__=='__main__':main()
|