import requests, json, urllib3
urllib3.disable_warnings()
BASE = "https://112.199.81.2:37443/api/v3/flows/executor/default-authentication-flow/"
H = {"Host":"www.itportal.cc","Content-Type":"application/json"}

# Test A: fresh session, POST uid_field directly (no GET first)
s = requests.Session(); s.verify=False
r = s.post(BASE, headers=H, data=json.dumps({"component":"ak-stage-identification","uid_field":"admin"}), allow_redirects=False, timeout=15)
print("A1 POST uid directly:", r.status_code, "loc=", r.headers.get("Location"))
try: print("  body:", r.text[:200])
except: pass
# then GET
r = s.get(BASE, headers={"Host":H["Host"]}, timeout=15)
try:
    j=r.json(); print("A2 GET:", r.status_code, "comp=", j.get("component"))
except: print("A2 GET:", r.status_code, r.text[:200])

# Test B: fresh session, POST password directly (no GET, no uid) - should fail gracefully
s2 = requests.Session(); s2.verify=False
r = s2.post(BASE, headers=H, data=json.dumps({"component":"ak-stage-password","password":"x"}), allow_redirects=False, timeout=15)
print("B1 POST pwd directly:", r.status_code, "comp=", (r.json() or {}).get("component") if r.headers.get('content-type','').startswith('application/json') else r.text[:100])
