38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from web.app import app
|
|
from web.session import _COOKIE_NAME, create_test_session
|
|
|
|
client = TestClient(app, raise_server_exceptions=True)
|
|
|
|
|
|
def test_admin_status_requires_admin():
|
|
cookie = create_test_session({"docusign_user_email": "user@example.com"})
|
|
resp = client.get("/api/admin/status", cookies={_COOKIE_NAME: cookie})
|
|
assert resp.status_code == 403
|
|
|
|
|
|
def test_admin_status_returns_build_details(monkeypatch):
|
|
import web.config as cfg
|
|
|
|
monkeypatch.setattr(cfg.settings, "admin_emails_raw", "admin@example.com")
|
|
monkeypatch.setattr(cfg.settings, "build_id", "testbuild")
|
|
monkeypatch.setattr(cfg.settings, "asset_version", "testbuild")
|
|
|
|
cookie = create_test_session({"docusign_user_email": "admin@example.com"})
|
|
resp = client.get("/api/admin/status", cookies={_COOKIE_NAME: cookie})
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["build_id"] == "testbuild"
|
|
assert data["asset_version"] == "testbuild"
|
|
|
|
|
|
def test_index_includes_asset_version(monkeypatch):
|
|
import web.config as cfg
|
|
|
|
monkeypatch.setattr(cfg.settings, "asset_version", "asset123")
|
|
resp = client.get("/")
|
|
assert resp.status_code == 200
|
|
assert "/static/js/app.js?v=asset123" in resp.text
|
|
assert "/static/css/base.css?v=asset123" in resp.text
|