#!/usr/bin/env python3 """With OPENFUT_FIFA17_APPLY_PROBE unset the apply MUST fall through to the Python passthrough -- i.e. exactly the behaviour that existed before the probe. That is the production-safety claim, so prove it rather than assert it.""" import subprocess import urllib.error import urllib.request LOG = "/home/alex/openfut-sold-staging/logs/utas-host.log" mark = sum(1 for _ in open(LOG)) before = subprocess.run(["python3", "/home/alex/OpenFUT/scripts/fifa17-apply-snapshot.py"], capture_output=True, text=True).stdout req = urllib.request.Request( "http://127.0.0.1:8299/ut/game/fifa17/item/resource/5001004", data=b'{"apply":[{"id":100000003}]}', headers={"X-OpenFUT-Game": "fifa17", "Content-Type": "application/json"}, method="POST") try: with urllib.request.urlopen(req, timeout=30) as r: st, body = r.status, r.read().decode() except urllib.error.HTTPError as e: st, body = e.code, e.read().decode() print(" status=%s body=%s" % (st, body)) print("--- log with the gate OFF ---") lines = list(open(LOG))[mark:] for line in lines: if any(k in line for k in ("apply-probe", "passthrough", "PYTHON")): print(" " + line.rstrip()[:150]) probe_served = any("apply-probe" in line for line in lines) went_python = any("owner=PYTHON" in line for line in lines) after = subprocess.run(["python3", "/home/alex/OpenFUT/scripts/fifa17-apply-snapshot.py"], capture_output=True, text=True).stdout print("\n probe served (must be False): %s" % probe_served) print(" proxied to Python (must be True): %s" % went_python) print(" Core unchanged: %s" % (before == after)) print("\nRESULT: %s" % ("OK -- gate fails closed" if (not probe_served and went_python and before == after) else "FAILED"))