367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
99 lines
5.3 KiB
Python
99 lines
5.3 KiB
Python
"""Fail-closed endpoint checks for direct local Tortoise client tests."""
|
|
|
|
TURTLE_AUTH_PORT = 3724
|
|
TURTLE_WORLD_PORT = 8090
|
|
GATEWAY_PORT = 19085
|
|
|
|
|
|
def require_native_gameplay_policy(policy):
|
|
"""No input may accumulate behind a disabled/failed Instance send route."""
|
|
if policy.get('enabled') is not True or policy.get('error') != 0:
|
|
raise RuntimeError('Enable the verified native channel policy before gameplay input; do not queue a retry')
|
|
|
|
|
|
def require_local_turtle_ports(ports):
|
|
"""Require real Turtle services and gateway-off; leave unrelated services alone."""
|
|
if GATEWAY_PORT in ports:
|
|
raise RuntimeError('Stop the external WoW-Hybrid gateway before native tests')
|
|
if not {TURTLE_AUTH_PORT, TURTLE_WORLD_PORT} <= set(ports):
|
|
raise RuntimeError('Require local Tortoise auth3724 and world8090 listeners')
|
|
|
|
|
|
def require_authenticated_turtle_realm(account):
|
|
"""Validate the actual proof-verified realm before any client transition."""
|
|
if account.get('server_proof_verified') != 1 or account.get('transport_prepared') != 1:
|
|
raise RuntimeError('Require a proof-verified Turtle session and prepared transport')
|
|
if account.get('auth_port') != TURTLE_AUTH_PORT:
|
|
raise RuntimeError('Native test authentication endpoint is not local Tortoise')
|
|
realms = account.get('realms')
|
|
selected = account.get('selected_index')
|
|
if not isinstance(realms, list) or not isinstance(selected, int) or not 0 <= selected < len(realms):
|
|
raise RuntimeError('Authenticated Turtle realm selection is unavailable')
|
|
if realms[selected].get('address') != '127.0.0.1:8090':
|
|
raise RuntimeError('Selected realm is not the local Tortoise world endpoint')
|
|
|
|
|
|
def require_native_world_observation(pipe, engine, ui_state):
|
|
"""Authorize read-only observation, never gameplay input or success claims.
|
|
|
|
The consumed self-create and live authenticated pipe are stronger readiness
|
|
evidence than OCR of an outlined zone label. Unknown OCR is acceptable only
|
|
for this read-only observer; screenshots retain their credential guard and
|
|
still require visual review. Known non-world screens always reject.
|
|
"""
|
|
world = pipe.get('world', {})
|
|
net = engine.get('netclient', {})
|
|
if (ui_state not in ('world', 'loading-or-unknown') or
|
|
pipe.get('error') != 0 or pipe.get('closed') != 0 or
|
|
pipe.get('world_auth') != 1 or world.get('login_sent') != 1 or
|
|
world.get('self_create') != 1 or net.get('state_enum') != 5 or
|
|
net.get('packet_host', {}).get('self_create_consumed') is not True):
|
|
raise RuntimeError('Require a live authenticated engine-consumed self-create for read-only world observation')
|
|
|
|
|
|
def require_solo_test_character(character, online_guids):
|
|
"""Source-online identity guard for reversible single-character fixtures.
|
|
|
|
Compare actual local server query output; never infer ownership from a
|
|
caller-supplied SQL baseline while a different character is being controlled.
|
|
Multiplayer tests must use an explicit separate multi-session contract.
|
|
"""
|
|
if type(character) is not int or not 0<character<2**32 or not isinstance(online_guids,str) or online_guids.splitlines()!=[str(character)]:
|
|
raise RuntimeError('Require the designated local character as the sole online test session')
|
|
|
|
|
|
def expected_gm_restore_auras(saved_rows, flags):
|
|
"""Player::SetGMVisible(false) legitimately recreates visual aura16380.
|
|
|
|
Saved rows before a fixture may lag live GM state. Permit only this exact
|
|
source-defined restoration addition, preserving all original rows/duplicates.
|
|
Other newly saved effects still fail the fixture's final comparison.
|
|
"""
|
|
if not isinstance(saved_rows,str) or type(flags) is not int or not 0<=flags<2**32:raise RuntimeError('Invalid saved aura restoration baseline')
|
|
rows=saved_rows.splitlines()
|
|
if len(rows)>1024 or any(not row.isascii() or not row.isdecimal() or not 0<int(row)<2**31 for row in rows):raise RuntimeError('Invalid source saved aura rows')
|
|
values=[int(row) for row in rows]
|
|
if flags&16 and 16380 not in values:values.append(16380)
|
|
return '\n'.join(map(str,sorted(values)))
|
|
|
|
|
|
def require_supported_pve_creature(source_rows, level):
|
|
"""Reject fixtures the current native unit-create profile cannot present.
|
|
|
|
Query name,level_min,level_max,rank,npc_flags,unit_class from the actual
|
|
template. Match turtle_presentable_creature_class, including unspecified0;
|
|
never invent a class or mutate authoritative server definitions.
|
|
Call before GM setup/summoning so ordinary UI cleanup remains possible.
|
|
"""
|
|
import re
|
|
if type(level) is not int or not 1<=level<=60 or not isinstance(source_rows,str):
|
|
raise RuntimeError('Invalid source creature fixture context')
|
|
row=source_rows.split('\t')
|
|
if (len(row)!=6 or not re.fullmatch(r'[A-Za-z -]{1,100}',row[0]) or
|
|
any(not re.fullmatch(r'[0-9]{1,10}',v) for v in row[1:])):
|
|
raise RuntimeError('Invalid source creature fixture row')
|
|
minimum,maximum,rank,flags,cls=map(int,row[1:])
|
|
if not 1<=minimum or not level-2<=minimum<=maximum<=level or rank or flags or cls not in (0,1,2,4,8):
|
|
raise RuntimeError('Require matched normal creature with source class supported by native create; do not summon unsupported fixture')
|
|
return row
|