Files
aios/scripts/run_full_uat.py
T

19 lines
1.0 KiB
Python

#!/usr/bin/env python3
import urllib.request, urllib.parse, json, http.cookiejar, sys, os
base=os.environ.get('AIOS_WEBOPS_BASE','http://127.0.0.1:18081')
cj=http.cookiejar.CookieJar(); opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
def post(path,data):
req=urllib.request.Request(base+path,data=json.dumps(data).encode(),headers={'Content-Type':'application/json'},method='POST')
return json.loads(opener.open(req,timeout=10).read().decode())
def form(path,data):
req=urllib.request.Request(base+path,data=urllib.parse.urlencode(data).encode(),headers={'Content-Type':'application/x-www-form-urlencoded'},method='POST')
return opener.open(req,timeout=10).read().decode()
def get(path): return opener.open(base+path,timeout=10).read().decode()
form('/login',{'username':'owner','password':'bootstrap-change-me'})
ready=get('/health/ready')
assert 'owner' in ready and 'server-hw' in ready
res=post('/api/uat/run',{})
print(json.dumps(res,ensure_ascii=False,indent=2))
if res.get('failed'): sys.exit(2)
print('FULL_UAT_PASS')