mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
feat: show the Headroom for Teams offer in the dashboard, docs, llms.txt and release notes (#3991)
## Description This PR puts the Headroom for Teams offer (3 months of Enterprise free with a 12-month plan) in the places people go after the README (#3990): the dashboard, the docs site, `llms.txt` and the release notes. Each link carries its own `utm_source`/`utm_medium`, so we can see which surface converts. No linked issue. ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Performance improvement - [ ] Code refactoring (no functional changes) ## Changes Made - **Dashboard:** a slim, dismissible banner under the header. It shows the user's savings when they are $1 or more. It is a plain link, so nothing is fetched or reported. - The banner is removed server-side on any **licensed** proxy, using the running proxy's effective licence: `ProxyConfig.license_key`, `HEADROOM_LICENSE`, or the deprecated `HEADROOM_LICENSE_KEY`. `create_app` resolves the licence once and passes it to `get_dashboard_html(licensed=...)`. This is a review fix: before, only `HEADROOM_LICENSE` was checked. - This only hides a promotion. OSS still needs no licence and checks none; licences belong to the Enterprise plugins. - **Docs site:** a dismissible top banner, a sidebar link and a new `/docs/teams` page. - The page's Open source vs Enterprise table now states what OSS already ships (tool search on Anthropic requests; opt-in, rule-based model routing) and what Enterprise adds. This is a review fix. - **`llms.txt`:** a Headroom for Teams section, with the same accuracy fix. - **Release notes:** a `release.yml` step appends one footer line under the changelog. It is keyed on its own marker, `<!-- headroom-teams-footer -->`, rather than on the perks link, so a changelog entry that mentions the link no longer suppresses the footer. This is a review fix. - **Telemetry opt-out:** `llms.txt` and `docs/content/docs/proxy.mdx` named a `--offline` flag that does not exist. The switch is `HEADROOM_OFFLINE=1`. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check .`) - [x] Type checking passes (`mypy headroom`) - [x] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ pytest -q tests/test_dashboard_teams_perk.py tests/test_dashboard_static_assets.py ============================= 17 passed in 18.40s ============================== # test_dashboard_teams_perk.py: renderer, with and without each licence env var and with an explicit flag; # /dashboard route, unlicensed, with ProxyConfig.license_key, with HEADROOM_LICENSE, with HEADROOM_LICENSE_KEY $ pytest -q tests -k "dashboard or release or license" 4 failed, 305 passed, 1 skipped # the 4 failures are tests/test_dashboard/test_live_feed.py (Playwright browser tests). They fail identically # on this branch without the review commit; it is this machine's browser setup. $ ruff check headroom/dashboard/__init__.py headroom/proxy/server.py tests/test_dashboard_teams_perk.py All checks passed! $ mypy headroom/dashboard/__init__.py --ignore-missing-imports Success: no issues found in 1 source file # release footer step, simulated twice on notes that already link the perks page: appended skipped # re-run is a no-op; footer present exactly once ``` ## Real Behavior Proof - Environment: macOS 26.6 (arm64), Python 3.12.13, FastAPI `TestClient` against `create_app`. - Exact command / steps: `pytest -q tests/test_dashboard_teams_perk.py`. The release step's shell was run twice against a notes file that already mentions `headroom-perks.vercel.app`. - Observed result: the `/dashboard` route serves the banner unlicensed, and strips it for each of the three licence sources while leaving the rest of the page intact. The footer is appended once and is not duplicated on a re-run. - Not tested: the release step against a real GitHub release (it runs on the next release), and the docs `next build` after this commit (only Markdown/MDX text changed). ## Runtime Rollout Safety - Rollout-managed feature(s): none. - Minimum rollout channel: stable. - Stable/default behavior changed: yes. Unlicensed dashboards show a dismissible banner, and the docs site shows a dismissible banner. - Kill switch / disable path: set any licence token to hide the dashboard banner. It is a plain link, with no network calls. - Unsafe override required: no. - Qualification impact: none. - Rollback path: revert this PR. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] I did **not** edit `CHANGELOG.md` — it is generated by release-please from my Conventional Commit PR title (a CI guard enforces this) ## Screenshots (if applicable) N/A ## Additional Notes - **Review fixes are in `eeb0008a`:** @JerrettDavis's two points (the effective licence source, and the OSS routing row) and Devin's footer-marker and `--offline` findings. - **Not changed:** Devin's suggestion to show sub-dollar savings. The $1 floor is deliberate, because "you saved $0.40" weakens the offer, and the cost card still shows the exact amount. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: JD Davis <mxjerrett@gmail.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
JD Davis
parent
3604af9bbe
commit
1ad92f0cbc
@@ -1062,6 +1062,26 @@ jobs:
|
||||
gh release create "$TAG" --title "$TITLE" --notes-file .changelog.md
|
||||
fi
|
||||
|
||||
# Appends once: a re-run finds this step's own marker and leaves the notes
|
||||
# alone. Keyed on the marker, not the link, so a changelog entry that
|
||||
# happens to mention the perks page does not suppress the footer.
|
||||
# Release notes stay the changelog; this is one line under it.
|
||||
- name: Add Headroom for Teams footer to release notes
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
TAG="v${{ needs.detect-version.outputs.version }}"
|
||||
MARKER='<!-- headroom-teams-footer -->'
|
||||
gh release view "$TAG" --json body --jq .body > release-notes.md
|
||||
if ! grep -qF "$MARKER" release-notes.md; then
|
||||
{
|
||||
printf '\n%s\n\n---\n\n' "$MARKER"
|
||||
printf '**Headroom for Teams:** 3 months of Headroom Enterprise free with a 12-month plan. '
|
||||
printf '[Claim the perk →](https://headroom-perks.vercel.app/?source=github&utm_source=github&utm_medium=release-notes&utm_content=%s)\n' "$TAG"
|
||||
} >> release-notes.md
|
||||
gh release edit "$TAG" --notes-file release-notes.md
|
||||
fi
|
||||
|
||||
- name: Publish ${{ env.PYPI_PACKAGE }} Python distributions to GitHub Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
+13
-1
@@ -1,4 +1,5 @@
|
||||
import { RootProvider } from 'fumadocs-ui/provider/next';
|
||||
import { Banner } from 'fumadocs-ui/components/banner';
|
||||
import './global.css';
|
||||
import { Inter } from 'next/font/google';
|
||||
import type { Metadata } from 'next';
|
||||
@@ -48,7 +49,18 @@ export default function Layout({ children }: LayoutProps<'/'>) {
|
||||
return (
|
||||
<html lang="en" className={inter.className} suppressHydrationWarning>
|
||||
<body className="flex flex-col min-h-screen">
|
||||
<RootProvider>{children}</RootProvider>
|
||||
<RootProvider>
|
||||
{/* Dismissible; Fumadocs remembers the dismissal per id in localStorage. */}
|
||||
<Banner id="teams-perk-2026">
|
||||
<a
|
||||
href="https://headroom-perks.vercel.app/?source=github&utm_source=docs&utm_medium=banner"
|
||||
className="font-medium underline-offset-4 hover:underline"
|
||||
>
|
||||
Headroom for Teams: 3 months free with a 12-month plan →
|
||||
</a>
|
||||
</Banner>
|
||||
{children}
|
||||
</RootProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"installation",
|
||||
"docker-install",
|
||||
"persistent-installs",
|
||||
"teams",
|
||||
"---Compression---",
|
||||
"how-compression-works",
|
||||
"smart-crusher",
|
||||
|
||||
@@ -36,7 +36,7 @@ Separately, an **anonymous usage beacon is on by default** (opt-out). Once a ses
|
||||
|
||||
The install id is a random UUID generated on first run and stored in your config directory. It is deliberately not derived from hostname, MAC address, or any hardware property — delete the file and you get a new one.
|
||||
|
||||
Disable it with `HEADROOM_BEACON=off`, the `DO_NOT_TRACK=1` convention, or `--offline` (which also disables update checks and license reporting).
|
||||
Disable it with `HEADROOM_BEACON=off`, the `DO_NOT_TRACK=1` convention, or `HEADROOM_OFFLINE=1` (which also disables update checks and license reporting).
|
||||
|
||||
## CLI options
|
||||
|
||||
@@ -401,7 +401,7 @@ with a privileged job.
|
||||
| `HEADROOM_PROXY_TOKEN` | none | Require a token from non-loopback callers, as `X-Headroom-Proxy-Token: <token>` or `Authorization: Bearer <token>`. The token is removed from the request before it is forwarded upstream; clients that also send a provider credential should use `X-Headroom-Proxy-Token` and keep `Authorization` for the provider. Also gates the read-only operator routes (`/stats-history`, `/quota`, `/subscription-window`, `/metrics`), which otherwise answer loopback and trusted-CIDR callers only. |
|
||||
| `HEADROOM_ALLOW_UNAUTHENTICATED_BIND` | `false` | Acknowledge a non-loopback bind (`--host 0.0.0.0`, `::`, a LAN address) with **no** `HEADROOM_PROXY_TOKEN`. Without a token or this flag the proxy refuses to start, because `/v1/*` would relay upstream with the operator's credentials for every peer that can reach the port. Only set it when the runtime already restricts reachability (a container published on `127.0.0.1`). |
|
||||
| `HEADROOM_COMPRESS_ALLOW_REMOTE` | `false` | Allow non-loopback callers to reach [`POST /v1/compress`](#post-v1compress) and `POST /v1/usage`. Required to run Headroom as a remote gateway/sidecar; without it remote callers get `404`. |
|
||||
| `--offline` / `HEADROOM_OFFLINE` | `false` | Air-gap mode: refuse every connection Headroom itself initiates — telemetry, update checks, license reporting, model/tokenizer/binary/dataset downloads, remote Kompress, OTLP and Langfuse export, Copilot auth, the subscription pollers, the OpenAI embedders, Headroom Cloud compression and the TLS diagnostics (`headroom doctor --network` reports them as skipped). Four things still work on purpose: forwarding your own requests to the upstream you configured, operator-configured local endpoints (the Ollama embedder), loopback health probes, and paths an `is_offline()` check already disables. Refusals surface as messages, not tracebacks. See the air-gap notes in `docs/metrics-technical-guide.md`. |
|
||||
| `HEADROOM_OFFLINE` | `false` | Air-gap mode: refuse every connection Headroom itself initiates — telemetry, update checks, license reporting, model/tokenizer/binary/dataset downloads, remote Kompress, OTLP and Langfuse export, Copilot auth, the subscription pollers, the OpenAI embedders, Headroom Cloud compression and the TLS diagnostics (`headroom doctor --network` reports them as skipped). Four things still work on purpose: forwarding your own requests to the upstream you configured, operator-configured local endpoints (the Ollama embedder), loopback health probes, and paths an `is_offline()` check already disables. Refusals surface as messages, not tracebacks. See the air-gap notes in `docs/metrics-technical-guide.md`. |
|
||||
| `HEADROOM_LICENSE` | unset | Licence token, read by core and every licensed extension. `HEADROOM_LICENSE_KEY` is a deprecated alias for one release and logs a warning. A licence on its own sends nothing to Headroom. |
|
||||
| `HEADROOM_USAGE_REPORTING` | `false` | Set `1` to let the proxy validate the licence and post aggregate usage counts (no content) to the Headroom cloud. Off unless set; `HEADROOM_OFFLINE` still overrides it. |
|
||||
| `--stateless` / `HEADROOM_STATELESS` | `false` | Keep all state in memory; no filesystem writes (disables logs, memory, TOIN). |
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Headroom for Teams
|
||||
description: Headroom Enterprise for engineering teams — more savings, automatic model routing, attack removal, SSO and an org-wide savings dashboard. 3 months free with a 12-month plan.
|
||||
---
|
||||
|
||||
Headroom OSS is built for one developer on one laptop. Headroom Enterprise is built
|
||||
for the whole team.
|
||||
|
||||
| | Open source | Enterprise |
|
||||
|---|---|---|
|
||||
| Savings | Compression, plus tool search on Anthropic requests (on by default) | Also: tool search for every model, harness tuning, extra compressors |
|
||||
| Model routing | Rule-based and opt-in: turn it on with `HEADROOM_MODEL_ROUTER_ENABLED=1` and write the rules in [`HEADROOM_MODEL_ROUTES`](/docs/configuration#cost-aware-model-routing) | Automatic: a cheaper model per request when quality allows, with a shadow mode that shows the savings before you turn it on |
|
||||
| Security | — | Detect and strip prompt injection and risky tool calls |
|
||||
| Rollout | Per laptop | Managed or in your VPC, SSO, central config, org-wide savings |
|
||||
| Support | GitHub, Discord | Dedicated engineers, onboarding, priority response |
|
||||
|
||||
## 3 months free
|
||||
|
||||
Companies that sign a 12-month Enterprise plan get their first 3 months free. One
|
||||
perk per company.
|
||||
|
||||
**[Claim 3 months free →](https://headroom-perks.vercel.app/?source=github&utm_source=docs&utm_medium=teams-page)**
|
||||
|
||||
Prefer to talk first? Email [hello@headroomlabs.ai](mailto:hello@headroomlabs.ai)
|
||||
with your stack and rough monthly LLM spend.
|
||||
|
||||
Everything in the open-source repo stays open source under Apache 2.0.
|
||||
@@ -6,5 +6,12 @@ export function baseOptions(): BaseLayoutProps {
|
||||
title: 'Headroom',
|
||||
},
|
||||
githubUrl: 'https://github.com/headroomlabs-ai/headroom',
|
||||
links: [
|
||||
{
|
||||
text: 'Headroom for Teams',
|
||||
url: '/docs/teams',
|
||||
active: 'nested-url',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Headroom Dashboard - Real-time proxy monitoring UI."""
|
||||
|
||||
import mimetypes
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
DASHBOARD_DIR = Path(__file__).parent
|
||||
@@ -49,10 +50,27 @@ def register_static_mime_types() -> None:
|
||||
mimetypes.add_type(mime_type, extension)
|
||||
|
||||
|
||||
def get_dashboard_html() -> str:
|
||||
"""Load the dashboard HTML template."""
|
||||
_TEAMS_PERK = re.compile(r"[ \t]*<!-- teams-perk:start.*?<!-- teams-perk:end -->\n?", re.DOTALL)
|
||||
|
||||
|
||||
def get_dashboard_html(*, licensed: bool | None = None) -> str:
|
||||
"""Load the dashboard HTML template.
|
||||
|
||||
The Headroom for Teams offer is stripped on a licensed install: it is
|
||||
already a customer. ``licensed`` is the running proxy's effective licence
|
||||
state (``create_app`` passes it, covering ``ProxyConfig.license_key``).
|
||||
When omitted it is resolved from the environment the same way the CLI
|
||||
does: ``HEADROOM_LICENSE``, or the deprecated ``HEADROOM_LICENSE_KEY``.
|
||||
"""
|
||||
template_path = TEMPLATES_DIR / "dashboard.html"
|
||||
return template_path.read_text(encoding="utf-8")
|
||||
html = template_path.read_text(encoding="utf-8")
|
||||
if licensed is None:
|
||||
from headroom.license_env import resolve_license_token
|
||||
|
||||
licensed = bool(resolve_license_token())
|
||||
if licensed:
|
||||
html = _TEAMS_PERK.sub("", html)
|
||||
return html
|
||||
|
||||
|
||||
def get_settings_html() -> str:
|
||||
|
||||
@@ -209,6 +209,26 @@
|
||||
</header>
|
||||
|
||||
<main class="p-6 max-w-7xl mx-auto">
|
||||
<!-- teams-perk:start — removed server-side when HEADROOM_LICENSE is set
|
||||
(see headroom.dashboard.get_dashboard_html). A plain link: nothing
|
||||
is fetched or reported, and dismissal stays in this browser. -->
|
||||
<aside data-testid="teams-perk" x-show="!teamsPerkDismissed"
|
||||
class="mb-6 flex flex-col gap-3 rounded-lg border border-accent/40 bg-surface p-4 md:flex-row md:items-center md:justify-between">
|
||||
<p class="text-sm text-gray-300">
|
||||
<span class="font-medium text-accent">Headroom for Teams</span>
|
||||
<span x-text="(stats.summary?.cost?.total_saved_usd || 0) >= 1
|
||||
? ' · You have saved $' + formatCurrency(stats.summary.cost.total_saved_usd) + ' on this machine. Get the same savings across your team, with 3 months free on a 12-month plan.'
|
||||
: ' · Bring these savings to your whole team, with 3 months free on a 12-month plan.'"></span>
|
||||
</p>
|
||||
<div class="flex items-center gap-3 shrink-0">
|
||||
<a href="https://headroom-perks.vercel.app/?source=github&utm_source=headroom&utm_medium=dashboard&utm_content=banner"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
class="px-3 py-1.5 text-sm font-medium rounded-md bg-accent text-black hover:opacity-90">Claim 3 months free →</a>
|
||||
<button type="button" @click="dismissTeamsPerk()" aria-label="Dismiss Headroom for Teams offer"
|
||||
class="text-sm text-gray-500 hover:text-gray-200">✕</button>
|
||||
</div>
|
||||
</aside>
|
||||
<!-- teams-perk:end -->
|
||||
<template x-if="viewMode === 'session'">
|
||||
<div data-testid="session-view">
|
||||
<p class="mb-4 text-xs text-gray-500">Current proxy process · runtime counters reset on restart</p>
|
||||
@@ -2033,6 +2053,14 @@
|
||||
function dashboard() {
|
||||
return {
|
||||
stats: {},
|
||||
teamsPerkDismissed: (() => {
|
||||
try { return localStorage.getItem('headroom-teams-perk-dismissed') === '1'; }
|
||||
catch (e) { return false; }
|
||||
})(),
|
||||
dismissTeamsPerk() {
|
||||
this.teamsPerkDismissed = true;
|
||||
try { localStorage.setItem('headroom-teams-perk-dismissed', '1'); } catch (e) {}
|
||||
},
|
||||
lifetimeStats: {},
|
||||
historyStats: {},
|
||||
healthy: true,
|
||||
|
||||
@@ -4537,11 +4537,17 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:
|
||||
# published on host loopback, whose peer is the bridge gateway, still loads.
|
||||
_dashboard_gate = [Depends(_require_operator_read_client)]
|
||||
|
||||
# Effective licence state of THIS proxy, resolved once: an explicit
|
||||
# ProxyConfig.license_key, else HEADROOM_LICENSE or its deprecated alias.
|
||||
from headroom.license_env import resolve_license_token
|
||||
|
||||
_dashboard_licensed = bool(config.license_key) or bool(resolve_license_token())
|
||||
|
||||
@app.get("/dashboard", response_class=HTMLResponse)
|
||||
@app.get("/dashboard/", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def dashboard():
|
||||
"""Serve the Headroom dashboard UI."""
|
||||
return get_dashboard_html()
|
||||
return get_dashboard_html(licensed=_dashboard_licensed)
|
||||
|
||||
# --- Dashboard settings API (loopback-gated, registry-validated) ---------
|
||||
# Read/write the curated HEADROOM_* knobs the settings GUI manages. Writes
|
||||
|
||||
@@ -62,6 +62,13 @@ The canonical, always-current documentation index lives at the docs site below.
|
||||
- [Troubleshooting](https://docs.headroomlabs.ai/docs/troubleshooting): Common failure modes and fixes.
|
||||
- [Limitations](https://docs.headroomlabs.ai/docs/limitations): What Headroom won't do well today.
|
||||
|
||||
## Headroom for Teams
|
||||
|
||||
For teams and companies that want Headroom across every developer rather than one laptop: Headroom Enterprise adds more savings (tool search for every model, harness tuning, extra compressors), automatic model routing (open source has opt-in, rule-based routing), prompt-injection and risky-tool-call removal, SSO, managed or VPC deployment, an org-wide savings dashboard, and support. Companies that sign a 12-month Enterprise plan get the first 3 months free.
|
||||
|
||||
- [Headroom for Teams](https://docs.headroomlabs.ai/docs/teams): Open source vs Enterprise, and the 3-months-free offer.
|
||||
- [Claim 3 months free](https://headroom-perks.vercel.app/?source=github&utm_source=llms-txt): Perk sign-up form. One perk per company.
|
||||
|
||||
## Licensing
|
||||
|
||||
Apache 2.0. Use commercially, modify, redistribute. Data stays on the user's machine when running the library, proxy, or MCP server locally. Anonymous telemetry is **off by default** (opt-in); enable with `HEADROOM_TELEMETRY=on` or `headroom proxy --telemetry`.
|
||||
Apache 2.0. Use commercially, modify, redistribute. Data stays on the user's machine when running the library, proxy, or MCP server locally. An anonymous usage beacon is **on by default**: it reports compression ratios, counters, provider and model IDs, OS and architecture, and never prompts, completions, code or file paths. Turn it off with `HEADROOM_BEACON=off`, `DO_NOT_TRACK=1`, or `HEADROOM_OFFLINE=1`. See [Telemetry](https://github.com/headroomlabs-ai/headroom#telemetry).
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""The Headroom for Teams offer shows on unlicensed installs only.
|
||||
|
||||
"Licensed" means the running proxy's effective licence, from any source the
|
||||
proxy accepts: an explicit ``ProxyConfig.license_key``, ``HEADROOM_LICENSE``, or
|
||||
the deprecated ``HEADROOM_LICENSE_KEY`` alias.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from headroom.dashboard import get_dashboard_html
|
||||
from headroom.proxy.server import ProxyConfig, create_app
|
||||
|
||||
_LICENSE_ENV = ("HEADROOM_LICENSE", "HEADROOM_LICENSE_KEY")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_license_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
for name in _LICENSE_ENV:
|
||||
monkeypatch.delenv(name, raising=False)
|
||||
|
||||
|
||||
def _assert_offer(html: str, shown: bool) -> None:
|
||||
assert ('data-testid="teams-perk"' in html) is shown
|
||||
assert ("headroom-perks.vercel.app" in html) is shown
|
||||
assert ("teams-perk:start" in html) is shown
|
||||
# Only the offer block ever goes; the dashboard around it is intact.
|
||||
assert 'data-testid="session-view"' in html
|
||||
assert html.count("<main") == 1
|
||||
|
||||
|
||||
def _dashboard(monkeypatch: pytest.MonkeyPatch, **config: object) -> str:
|
||||
monkeypatch.setenv("HEADROOM_SKIP_UPSTREAM_CHECK", "1")
|
||||
app = create_app(
|
||||
ProxyConfig(
|
||||
optimize=False,
|
||||
cache_enabled=False,
|
||||
rate_limit_enabled=False,
|
||||
cost_tracking_enabled=False,
|
||||
log_requests=False,
|
||||
http2=False,
|
||||
**config,
|
||||
)
|
||||
)
|
||||
with TestClient(app) as client:
|
||||
response = client.get("/dashboard")
|
||||
assert response.status_code == 200
|
||||
return response.text
|
||||
|
||||
|
||||
# --- renderer ---------------------------------------------------------------
|
||||
|
||||
|
||||
def test_offer_shown_without_license() -> None:
|
||||
_assert_offer(get_dashboard_html(), shown=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("env", _LICENSE_ENV)
|
||||
def test_offer_removed_with_license_env(monkeypatch: pytest.MonkeyPatch, env: str) -> None:
|
||||
monkeypatch.setenv(env, "hlk_test")
|
||||
_assert_offer(get_dashboard_html(), shown=False)
|
||||
|
||||
|
||||
def test_explicit_licensed_flag_wins_over_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_assert_offer(get_dashboard_html(licensed=True), shown=False)
|
||||
monkeypatch.setenv("HEADROOM_LICENSE", "hlk_test")
|
||||
_assert_offer(get_dashboard_html(licensed=False), shown=True)
|
||||
|
||||
|
||||
# --- /dashboard route: the effective licence of the running proxy -------------
|
||||
|
||||
|
||||
def test_route_shows_offer_unlicensed(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_assert_offer(_dashboard(monkeypatch), shown=True)
|
||||
|
||||
|
||||
def test_route_hides_offer_with_configured_license_key(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_assert_offer(_dashboard(monkeypatch, license_key="hlk_configured"), shown=False)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("env", _LICENSE_ENV)
|
||||
def test_route_hides_offer_with_license_env(monkeypatch: pytest.MonkeyPatch, env: str) -> None:
|
||||
monkeypatch.setenv(env, "hlk_test")
|
||||
_assert_offer(_dashboard(monkeypatch), shown=False)
|
||||
Reference in New Issue
Block a user