hi
This commit is contained in:
commit
2a63bc4e50
14 files changed
+1104
No files matched your search
@@ -0,0 +1,26 @@
|
||||
"""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")
|
||||
Reference in new issue
Block a user