27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
"""Manual browser-QA companion. Uses only disposable preview_* accounts."""
|
|
import hashlib
|
|
import json
|
|
from urllib.request import Request,urlopen
|
|
from urllib.error import HTTPError
|
|
|
|
|
|
def post(path,body,token=None):
|
|
headers={"Content-Type":"application/json"}
|
|
if token:headers["Authorization"]="Bearer "+token
|
|
request=Request("http://127.0.0.1:8789/api"+path,json.dumps(body).encode(),headers,method="POST")
|
|
try:
|
|
with urlopen(request,timeout=10) as response:return response.status,json.load(response)
|
|
except HTTPError as error:return error.code,json.load(error)
|
|
|
|
|
|
if __name__=="__main__":
|
|
hardware=hashlib.sha256(b"disposable browser qa device").hexdigest()
|
|
status,result=post("/client/activate",{"username":"preview_member","password":"local-qa-member-2026","hwid":hardware,"device_name":"preview desktop"})
|
|
assert status==200,result
|
|
token=result["token"]
|
|
status,verified=post("/client/verify",{"hwid":hardware},token)
|
|
assert status==200 and verified["valid"],verified
|
|
status,rejected=post("/client/verify",{"hwid":"b"*64},token)
|
|
assert status==403 and rejected["code"]=="hwid_mismatch",rejected
|
|
print(f"PASS: production HTTP server activation, UID {verified['account']['uid']}, device tie, token verification and wrong-device rejection")
|