import json,urllib.error,urllib.request from pathlib import Path token=json.loads((Path(__file__).resolve().parent/'client.json').read_text())['token'] for port in (18792,18794): base=f'http://192.168.110.111:{port}' for authorized in (False,True): headers={'Authorization':'Bearer '+token} if authorized else {} req=urllib.request.Request(base+'/v2/video_generation/huobao-nonexistent-verification-id/cancel',data=b'{}',headers=headers,method='POST') try:urllib.request.urlopen(req,timeout=10);raise AssertionError('Unknown job accepted') except urllib.error.HTTPError as e:assert e.code==(404 if authorized else 401),(port,e.code) req=urllib.request.Request(base+'/v1/models',headers={'Authorization':'Bearer '+token}) with urllib.request.urlopen(req,timeout=20) as r: models=json.load(r) print(json.dumps({'port':port,'auth_required':True,'unknown_cancel_rejected':True,'models_available':len(models['data'])}))