36 lines
2.0 KiB
Python
36 lines
2.0 KiB
Python
import urllib.request,ssl,http.cookiejar,json,time
|
|
|
|
ctx=ssl._create_unverified_context()
|
|
cj=http.cookiejar.CookieJar()
|
|
o=urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj),urllib.request.HTTPSHandler(context=ctx))
|
|
o.open(urllib.request.Request("https://weval-consulting.com/login",data=b"user=yacine&pass=Weval@2026",method="POST"),timeout=10)
|
|
|
|
results=[]
|
|
for msg,name in [("salut","greeting"),("etat systeme","infra"),("providers actifs","providers"),("qdrant autolearn","qdrant"),("scan complet","scan"),("docker status","docker")]:
|
|
try:
|
|
s=time.time()
|
|
r=o.open(urllib.request.Request("https://weval-consulting.com/api/wevia-autonomous.php",data=json.dumps({"message":msg,"history":[]}).encode(),headers={"Content-Type":"application/json"}),timeout=25)
|
|
body=r.read().decode("utf-8","replace")
|
|
ms=int((time.time()-s)*1000)
|
|
has_auth="uthentik" in body.lower()
|
|
has_curl="curl " in body and "action=" in body
|
|
has_exec="action_done" in body
|
|
has_text=any('"type":"text"' in l for l in body.split("\n"))
|
|
# Extract response text
|
|
resp=""
|
|
for l in body.split("\n"):
|
|
if '"type":"text"' in l:
|
|
try:
|
|
d=json.loads(l[5:])
|
|
resp+=d.get("content","")
|
|
except:pass
|
|
results.append({"q":msg,"name":name,"auth":has_auth,"curl":has_curl,"exec":has_exec,"text":has_text,"ms":ms,"resp":resp[:200],"ok":has_text and not has_auth})
|
|
print(f"{'OK' if has_text and not has_auth else 'FL'} {name:12} {ms}ms auth={has_auth} curl={has_curl} exec={has_exec}")
|
|
except Exception as e:
|
|
results.append({"q":msg,"name":name,"ok":False,"err":str(e)[:50]})
|
|
print(f"ER {name:12} {str(e)[:50]}")
|
|
|
|
ok=sum(1 for r in results if r.get("ok"))
|
|
json.dump({"results":results,"ok":ok,"total":len(results),"ts":time.strftime("%c")},open("/var/www/html/api/wevia-full-test-results.json","w"),indent=2)
|
|
print(f"\nFINAL: {ok}/{len(results)} OK")
|