| 1 | import asyncio |
| 2 | import sys |
| 3 | from pathlib import Path |
| 4 | |
| 5 | |
| 6 | PROJECT_ROOT = Path(__file__).resolve().parents[1] |
| 7 | if str(PROJECT_ROOT) not in sys.path: |
| 8 | sys.path.insert(0, str(PROJECT_ROOT)) |
| 9 | |
| 10 | from extensions.python.banners import _10_unsecured_connection as unsecured_connection |
| 11 | |
| 12 | |
| 13 | def test_unsecured_connection_banner_opens_authentication_settings(monkeypatch): |
| 14 | monkeypatch.setattr( |
| 15 | unsecured_connection.dotenv, |
| 16 | "get_dotenv_value", |
| 17 | lambda key, default="": "", |
| 18 | ) |
| 19 | |
| 20 | banners = [] |
| 21 | asyncio.run( |
| 22 | unsecured_connection.UnsecuredConnectionCheck(agent=None).execute( |
| 23 | banners=banners, |
| 24 | frontend_context={"hostname": "agent.example.com", "protocol": "http:"}, |
| 25 | ) |
| 26 | ) |
| 27 | |
| 28 | row = next(banner for banner in banners if banner.get("id") == "unsecured-connection") |
| 29 | assert 'href="#section-auth"' in row["html"] |
| 30 | assert 'data-banner-action="open-modal:settings/settings.html#section-auth"' in row["html"] |
| 31 | assert "onclick" not in row["html"] |