tests - add more logs when http test fail

This commit is contained in:
florian 2024-04-09 16:15:59 +02:00
parent dba057f010
commit 5505f62d1e
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500

View file

@ -138,9 +138,13 @@ class Test(ABC):
if test["type"] == "string":
r = get(ex_url, timeout=10, verify=False)
ok = test["string"].casefold() in r.text.casefold()
if not ok:
log("TEST", "⚠️", f"String not found : {test['string'].casefold()}")
elif test["type"] == "status":
r = get(ex_url, timeout=10, verify=False)
ok = test["status"] == r.status_code
if not ok:
log("TEST", "⚠️", f"Wrong status code : {str(r.status_code)}")
if ok and "tls" in test:
ex_tls = test["tls"]
tls_edit = True
@ -161,6 +165,7 @@ class Test(ABC):
log("TEST", "⚠️", f"wrong cert CN : {x509.get_subject().CN} != {ex_tls}")
return ok
except:
log("TEST", "⚠️", f"Exception : {format_exc()}")
return False
raise (Exception(f"unknown test type {test['type']}"))