mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
curl tests: ignore yunohost-injected css/js when testing app assets
This commit is contained in:
parent
6680eb56e6
commit
83a4ef3f64
1 changed files with 7 additions and 3 deletions
|
@ -135,17 +135,21 @@ def test(base_url, path, post=None, logged_on_sso=False, expect_return_code=200,
|
||||||
if auto_test_assets:
|
if auto_test_assets:
|
||||||
assets_to_check = []
|
assets_to_check = []
|
||||||
stylesheets = html.find_all("link", rel="stylesheet", href=True)
|
stylesheets = html.find_all("link", rel="stylesheet", href=True)
|
||||||
|
stylesheets = [s for s in stylesheets if "ynh_portal" not in s["href"] and "ynhtheme" not in s["href"]]
|
||||||
if stylesheets:
|
if stylesheets:
|
||||||
assets_to_check.append(stylesheets[0]['href'])
|
assets_to_check.append(stylesheets[0]['href'])
|
||||||
js = html.find_all("script", src=True)
|
js = html.find_all("script", src=True)
|
||||||
|
js = [s for s in js if "ynh_portal" not in s["src"] and "ynhtheme" not in s["src"]]
|
||||||
if js:
|
if js:
|
||||||
assets_to_check.append(js[0]['src'])
|
assets_to_check.append(js[0]['src'])
|
||||||
if not assets_to_check:
|
if not assets_to_check:
|
||||||
print("\033[1m\033[93mWARN\033[0m auto_test_assets set to true, but no js/css asset found in this page")
|
print("\033[1m\033[93mWARN\033[0m auto_test_assets set to true, but no js/css asset found in this page")
|
||||||
for asset in assets_to_check:
|
for asset in assets_to_check:
|
||||||
code, _, _ = curl(f"https://{domain}", asset, use_cookies=cookies)
|
if asset.startswith(f"https://{domain}"):
|
||||||
|
asset = asset.replace(f"https://{domain}", "")
|
||||||
|
code, _, effective_url = curl(f"https://{domain}", asset, use_cookies=cookies)
|
||||||
if code != 200:
|
if code != 200:
|
||||||
errors.append(f"Asset https://{domain}{asset} (automatically derived from the page's html) answered with code {code}, expected 200?")
|
errors.append(f"Asset https://{domain}{asset} (automatically derived from the page's html) answered with code {code}, expected 200? Effective url: {effective_url}")
|
||||||
assets.append((domain + asset, code))
|
assets.append((domain + asset, code))
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +201,7 @@ def display_result(result):
|
||||||
print(f"Title : {result['title'].strip()}")
|
print(f"Title : {result['title'].strip()}")
|
||||||
print(f"Content extract:\n{result['content'][:250].strip()}")
|
print(f"Content extract:\n{result['content'][:250].strip()}")
|
||||||
if result["assets"]:
|
if result["assets"]:
|
||||||
print(f"Assets :")
|
print("Assets :")
|
||||||
for asset, code in result["assets"]:
|
for asset, code in result["assets"]:
|
||||||
if code == 200:
|
if code == 200:
|
||||||
print(f" - {asset}")
|
print(f" - {asset}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue