Make the landing page look like something worth having a key for
CI / test (push) Successful in 1m30s
CI / test (push) Successful in 1m30s
It is the only page a stranger sees, and until they have a key it is the whole product: a stack of headings and shell snippets said "internal tool you probably should not be here". Now it opens with what this is and a diagram of why it exists — one address, many GPUs, fabrics that cannot see each other — then the base URL as a headline rather than a line of prose with a colon in it, the route to a key as three cards, and the client examples as tabs instead of a pile. The tabs are radio buttons and a stylesheet. No JavaScript decides what is on the page, so someone who arrives with scripting off still gets every example; the only script is the copy buttons, which exist only where the clipboard API does and so cannot leave a dead control behind. The page says exactly what it said before, including that it lists no models and why. The diagram names no model, no node and no count: fabrics are drawn because llmgw keeps them apart, not because this install has two. Tests cover the parts that are easy to break later: every example lives in the page itself rather than being fetched per tab, the reflected base URL — now in five places rather than one — still cannot write markup, and the diagram carries a label for anyone not looking at it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f8bb78103f
commit
0cac9d6986
3 files changed
+331
-50
No files matched your search
@@ -170,3 +170,95 @@ select { font: inherit; padding: .35rem .4rem; border: 1px solid var(--line);
|
||||
* design width so scaling up never inflates the 12px labels. */
|
||||
.ranked { margin: .25rem 0 1rem; }
|
||||
.ranked svg { display: block; width: 100%; max-width: 720px; height: auto; }
|
||||
|
||||
/* The landing page.
|
||||
*
|
||||
* It is the only page here a stranger sees, and for most readers it is the whole
|
||||
* product until they have a key. Everything below is layout and surface: the
|
||||
* page still says exactly what it said before, and still names no model, no node
|
||||
* and no count. */
|
||||
.banner { border-radius: 6px; padding: .7rem .9rem; margin: 0 0 1.5rem;
|
||||
border: 1px solid var(--line); background: var(--card); font-size: .875rem; }
|
||||
.warn-banner { border-color: var(--warn); color: var(--warn); }
|
||||
|
||||
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
|
||||
gap: 2rem; align-items: center; border-bottom: 1px solid var(--line);
|
||||
margin-bottom: 2.25rem; padding-bottom: 2rem; }
|
||||
.hero h1 { font-size: 2.6rem; line-height: 1; margin: 0 0 .5rem; letter-spacing: -.03em; }
|
||||
.hero .sub { font-size: 1.15rem; color: var(--fg); font-weight: 500; }
|
||||
.hero .lede { color: var(--muted); max-width: 34rem; margin: .75rem 0 0; }
|
||||
.cta { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.35rem 0 0; }
|
||||
.btn { display: inline-block; font-size: .9rem; font-weight: 600; text-decoration: none;
|
||||
background: var(--accent); color: var(--bg); border: 1px solid var(--accent);
|
||||
border-radius: 6px; padding: .5rem 1.1rem; }
|
||||
.btn:hover { filter: brightness(1.1); }
|
||||
.btn.ghost { background: none; color: var(--accent); border-color: var(--line); }
|
||||
.btn.ghost:hover { border-color: var(--accent); filter: none; }
|
||||
|
||||
.schematic { margin: 0; }
|
||||
.schematic svg { display: block; width: 100%; height: auto; }
|
||||
.schematic figcaption { color: var(--muted); font-size: .8rem; margin-top: .6rem; }
|
||||
@media (max-width: 760px) {
|
||||
.hero { grid-template-columns: 1fr; gap: 1.5rem; }
|
||||
.hero h1 { font-size: 2rem; }
|
||||
}
|
||||
|
||||
/* The base URL is what a reader came for, so it is a headline rather than a
|
||||
* line of prose with a colon in it. */
|
||||
.url-card { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem;
|
||||
background: var(--card); border: 1px solid var(--line);
|
||||
border-left: 3px solid var(--accent); border-radius: 6px;
|
||||
padding: .85rem 1.1rem; }
|
||||
.url-card .k { font-size: .72rem; font-weight: 600; text-transform: uppercase;
|
||||
letter-spacing: .06em; color: var(--muted); }
|
||||
.url-card code { font-size: 1.05rem; word-break: break-all; }
|
||||
|
||||
.steps { list-style: none; padding: 0; margin: .5rem 0 0;
|
||||
display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.steps > li { margin: 0; background: var(--card); border: 1px solid var(--line);
|
||||
border-radius: 8px; padding: 1.1rem 1.1rem 1.25rem; }
|
||||
.steps .n { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem;
|
||||
border-radius: 50%; background: var(--accent); color: var(--bg);
|
||||
font-size: .8rem; font-weight: 700; }
|
||||
.steps h3 { font-size: .98rem; margin: .6rem 0 .4rem; }
|
||||
.steps p { margin: .4rem 0 0; font-size: .9rem; }
|
||||
/* A card is narrower than a line of shell, and a block that scrolls sideways
|
||||
* inside a card is one nobody discovers they can scroll. */
|
||||
.steps pre { margin: .7rem 0 0; font-size: .78em;
|
||||
white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
@media (max-width: 860px) { .steps { grid-template-columns: 1fr; } }
|
||||
|
||||
/* Tabs with no JavaScript: the radios carry the state, so the panel a reader
|
||||
* chose survives everything including the script never loading. */
|
||||
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .75rem; }
|
||||
.tabs > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
|
||||
.tabs > label { display: inline-block; margin: 0; cursor: pointer; font-size: .85rem;
|
||||
font-weight: 600; color: var(--muted); padding: .35rem .85rem;
|
||||
border: 1px solid transparent; border-radius: 999px; }
|
||||
.tabs > label:hover { color: var(--fg); }
|
||||
.tabs > input:checked + label { color: var(--fg); background: var(--card);
|
||||
border-color: var(--line); }
|
||||
.tabs > input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
.tabs > .panels { flex: 1 0 100%; }
|
||||
.tabs .panel { display: none; margin: 0; }
|
||||
.tabs > input:nth-of-type(1):checked ~ .panels > .panel:nth-child(1),
|
||||
.tabs > input:nth-of-type(2):checked ~ .panels > .panel:nth-child(2),
|
||||
.tabs > input:nth-of-type(3):checked ~ .panels > .panel:nth-child(3) { display: block; }
|
||||
|
||||
/* Copy buttons are injected by script, so they are positioned against the block
|
||||
* they copy rather than reserving space that stays empty without one. */
|
||||
pre { position: relative; }
|
||||
pre .copy { position: absolute; top: .4rem; right: .4rem; padding: .15rem .5rem;
|
||||
font-size: .72rem; font-weight: 600; background: var(--bg);
|
||||
color: var(--muted); border: 1px solid var(--line); border-radius: 4px;
|
||||
opacity: 0; transition: opacity .12s; }
|
||||
pre:hover .copy, pre .copy:focus-visible { opacity: 1; }
|
||||
pre .copy:hover { color: var(--fg); filter: none; }
|
||||
|
||||
.endpoints { list-style: none; padding: 0; margin: .5rem 0 0; }
|
||||
.endpoints > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem;
|
||||
padding: .55rem 0; border-bottom: 1px solid var(--line); margin: 0; }
|
||||
.endpoints > li:last-child { border-bottom: none; }
|
||||
.endpoints > li span { color: var(--muted); font-size: .85rem; }
|
||||
/* A button revealed by hover is a button a phone never has. */
|
||||
@media (hover: none) { pre .copy { opacity: 1; } }
|
||||
@@ -1,68 +1,214 @@
|
||||
{{define "landing"}}<!doctype html>
|
||||
<html lang="en"><head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>llmgw</title><link rel="stylesheet" href="/_static/base.css">
|
||||
<title>llmgw</title>
|
||||
<meta name="description" content="One OpenAI-compatible endpoint in front of self-hosted models.">
|
||||
<link rel="stylesheet" href="/_static/base.css">
|
||||
</head><body><div class="wrap">
|
||||
<header>
|
||||
<h1>llmgw</h1>
|
||||
<p class="sub">An OpenAI-compatible endpoint in front of self-hosted models.</p>
|
||||
|
||||
{{if .Notice}}<p class="banner note">{{.Notice}}</p>{{end}}
|
||||
{{if not .AuthEnabled}}
|
||||
<p class="banner warn-banner">This gateway has no API keys configured, so it serves anyone
|
||||
who can reach it. That is a deployment choice, and only safe on a trusted network.</p>
|
||||
{{end}}
|
||||
|
||||
<header class="hero">
|
||||
<div class="hero-text">
|
||||
<h1>llmgw</h1>
|
||||
<p class="sub">One OpenAI-compatible endpoint in front of your own GPUs.</p>
|
||||
<p class="lede">Point any OpenAI client at this address. The API is the one you
|
||||
already have a client for — only the base URL changes.</p>
|
||||
<p class="cta">
|
||||
{{if .SignupOpen}}<a class="btn" href="/signup">Create an account</a>
|
||||
<a class="btn ghost" href="/login">Sign in</a>
|
||||
{{else if .AuthEnabled}}<a class="btn" href="/login">Sign in</a>{{end}}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{/* A schematic of what this is, not of what is installed here. It names no
|
||||
model, no node and no count: this page is served to anyone who can reach
|
||||
the address. */}}
|
||||
<figure class="schematic" aria-labelledby="schematic-cap">
|
||||
<svg viewBox="0 0 420 200" role="img"
|
||||
aria-label="Clients reach one endpoint, which places work on GPU nodes across separate fabrics.">
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="6" markerHeight="6" orient="auto">
|
||||
<path d="M0 0 L8 4 L0 8 z" fill="var(--viz-grid)"/>
|
||||
</marker>
|
||||
</defs>
|
||||
|
||||
<!-- clients -->
|
||||
<g font-size="10" fill="var(--muted)">
|
||||
<rect x="2" y="42" width="84" height="26" rx="6" fill="var(--card)" stroke="var(--line)"/>
|
||||
<text x="44" y="59" text-anchor="middle" fill="var(--fg)">your client</text>
|
||||
<rect x="2" y="86" width="84" height="26" rx="6" fill="var(--card)" stroke="var(--line)"/>
|
||||
<text x="44" y="103" text-anchor="middle" fill="var(--fg)">editor agent</text>
|
||||
<rect x="2" y="130" width="84" height="26" rx="6" fill="var(--card)" stroke="var(--line)"/>
|
||||
<text x="44" y="147" text-anchor="middle" fill="var(--fg)">a script</text>
|
||||
</g>
|
||||
<g fill="none" stroke="var(--viz-grid)" stroke-width="2" marker-end="url(#a)">
|
||||
<path d="M88 55 C 118 55 118 92 146 92"/>
|
||||
<path d="M88 99 h58"/>
|
||||
<path d="M88 143 C 118 143 118 108 146 108"/>
|
||||
</g>
|
||||
|
||||
<!-- the gateway -->
|
||||
<rect x="150" y="70" width="72" height="60" rx="8"
|
||||
fill="var(--accent)" opacity=".12" stroke="var(--accent)" stroke-width="1.5"/>
|
||||
<text x="186" y="96" text-anchor="middle" font-size="12" font-weight="600"
|
||||
fill="var(--fg)">llmgw</text>
|
||||
<text x="186" y="112" text-anchor="middle" font-size="9"
|
||||
fill="var(--muted)">one address</text>
|
||||
|
||||
<g fill="none" stroke="var(--viz-grid)" stroke-width="2" marker-end="url(#a)">
|
||||
<path d="M224 88 C 254 88 254 46 286 46"/>
|
||||
<path d="M224 112 C 254 112 254 146 286 146"/>
|
||||
</g>
|
||||
|
||||
<!-- two fabrics that cannot see each other -->
|
||||
<g font-size="9" fill="var(--muted)">
|
||||
<rect x="288" y="18" width="128" height="58" rx="8"
|
||||
fill="none" stroke="var(--line)" stroke-dasharray="4 3"/>
|
||||
<text x="296" y="32">fabric</text>
|
||||
<rect x="296" y="40" width="26" height="26" rx="4" fill="var(--viz-1)" opacity=".85"/>
|
||||
<rect x="330" y="40" width="26" height="26" rx="4" fill="var(--viz-1)" opacity=".85"/>
|
||||
<rect x="364" y="40" width="26" height="26" rx="4" fill="var(--viz-1)" opacity=".85"/>
|
||||
|
||||
<rect x="288" y="118" width="128" height="58" rx="8"
|
||||
fill="none" stroke="var(--line)" stroke-dasharray="4 3"/>
|
||||
<text x="296" y="132">fabric</text>
|
||||
<rect x="296" y="140" width="26" height="26" rx="4" fill="var(--viz-3)" opacity=".85"/>
|
||||
<rect x="330" y="140" width="26" height="26" rx="4" fill="var(--viz-3)" opacity=".85"/>
|
||||
<rect x="364" y="140" width="26" height="26" rx="4" fill="var(--viz-3)" opacity=".85"/>
|
||||
</g>
|
||||
</svg>
|
||||
<figcaption id="schematic-cap">Clients see one address. Work is placed on GPUs that
|
||||
can actually run it — and a model split across machines never straddles two fabrics.</figcaption>
|
||||
</figure>
|
||||
</header>
|
||||
|
||||
<p>Point any OpenAI client at this address. The API is the one you already have a
|
||||
client for; only the base URL changes.</p>
|
||||
<section class="url-card">
|
||||
<span class="k">Base URL</span>
|
||||
<code>{{.BaseURL}}/v1</code>
|
||||
</section>
|
||||
|
||||
<h2>Base URL</h2>
|
||||
<pre>{{.BaseURL}}/v1</pre>
|
||||
<h2>Three steps</h2>
|
||||
<ol class="steps">
|
||||
<li>
|
||||
<span class="n">1</span>
|
||||
<h3>Get a key</h3>
|
||||
{{if .SignupOpen}}
|
||||
<p><a href="/signup">Create an account</a>. Someone approves it, and then you issue
|
||||
your own keys from your <a href="/profile">profile</a> — as many as you need,
|
||||
revoking them yourself when a laptop is retired or a script is done.</p>
|
||||
{{else if .Contact}}
|
||||
<p>Ask {{if .ContactHref}}<a href="{{.ContactHref}}">{{.Contact}}</a>{{else}}<strong>{{.Contact}}</strong>{{end}}
|
||||
for one.{{if .AuthEnabled}} If you already have an account,
|
||||
<a href="/login">sign in</a>.{{end}}</p>
|
||||
{{else}}
|
||||
<p>Keys are issued by whoever operates this gateway. If you do not know who that
|
||||
is, the address you reached this page at is the place to start asking.</p>
|
||||
{{end}}
|
||||
<p class="note">A key is shown once and never again — only its hash is kept here —
|
||||
so put it in a password manager straight away.</p>
|
||||
</li>
|
||||
<li>
|
||||
<span class="n">2</span>
|
||||
<h3>Point your client at it</h3>
|
||||
<p>Set the base URL above and your key. Every OpenAI SDK, and every tool built on
|
||||
one, takes both as configuration.</p>
|
||||
<pre><code>export OPENAI_BASE_URL={{.BaseURL}}/v1
|
||||
export OPENAI_API_KEY=$LLMGW_API_KEY</code></pre>
|
||||
</li>
|
||||
<li>
|
||||
<span class="n">3</span>
|
||||
<h3>Pick a model</h3>
|
||||
{{if .AuthEnabled}}
|
||||
<p><code>GET /v1/models</code> lists what is available to your key. It needs the
|
||||
key, which is why this page does not list them: this page is served to anyone who
|
||||
can reach the address.</p>
|
||||
{{else}}
|
||||
<p><code>GET /v1/models</code> lists what is available.</p>
|
||||
{{end}}
|
||||
<p class="note">Sending the placeholder <code><model-name></code> unchanged is
|
||||
answered with the list of models you may use, rather than with an error.</p>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h2>Example</h2>
|
||||
<pre>curl {{.BaseURL}}/v1/chat/completions \
|
||||
<h2>Connect your client</h2>
|
||||
<div class="tabs">
|
||||
<input type="radio" name="client" id="tab-curl" checked><label for="tab-curl">curl</label>
|
||||
<input type="radio" name="client" id="tab-py"><label for="tab-py">Python</label>
|
||||
<input type="radio" name="client" id="tab-oc"><label for="tab-oc">OpenCode</label>
|
||||
<div class="panels">
|
||||
<pre class="panel"><code>curl {{.BaseURL}}/v1/chat/completions \
|
||||
-H "Authorization: Bearer $LLMGW_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"model": "<model-name>", "messages": [{"role":"user","content":"hello"}]}'</pre>
|
||||
<p class="note">
|
||||
Replace <model-name> with a name from
|
||||
<code>GET {{.BaseURL}}/v1/models</code>, which needs your key. Sending the
|
||||
placeholder unchanged is answered with the list of models that are available.
|
||||
</p>
|
||||
-d '{"model": "<model-name>",
|
||||
"messages": [{"role": "user", "content": "hello"}]}'</code></pre>
|
||||
|
||||
<pre>from openai import OpenAI
|
||||
client = OpenAI(base_url="{{.BaseURL}}/v1", api_key=os.environ["LLMGW_API_KEY"])</pre>
|
||||
<pre class="panel"><code>import os
|
||||
from openai import OpenAI
|
||||
|
||||
<h2>Which models</h2>
|
||||
{{if .AuthEnabled}}
|
||||
<p><code>GET /v1/models</code> lists what is available to your key. It needs the key,
|
||||
which is why this page does not list them: this page is served to anyone who can
|
||||
reach the address.</p>
|
||||
{{else}}
|
||||
<p><code>GET /v1/models</code> lists what is available.</p>
|
||||
<p class="note">This gateway has no API keys configured, so it serves anyone who can
|
||||
reach it. That is a deployment choice and only safe on a trusted network.</p>
|
||||
{{end}}
|
||||
client = OpenAI(base_url="{{.BaseURL}}/v1",
|
||||
api_key=os.environ["LLMGW_API_KEY"])
|
||||
|
||||
<h2>Getting a key</h2>
|
||||
{{if .SignupOpen}}
|
||||
<p><a href="/signup">Create an account</a>. Someone will approve it, and then you
|
||||
can issue your own keys from your <a href="/profile">profile</a> — as many as you
|
||||
need, revoking them yourself when a laptop is retired or a script is done.</p>
|
||||
<p class="note">Already have an account? <a href="/login">Sign in</a>.</p>
|
||||
{{else if .Contact}}
|
||||
<p>Ask {{if .ContactHref}}<a href="{{.ContactHref}}">{{.Contact}}</a>{{else}}<strong>{{.Contact}}</strong>{{end}}
|
||||
for one. {{if .AuthEnabled}}If you already have an account,
|
||||
<a href="/login">sign in</a>.{{end}}</p>
|
||||
{{else}}
|
||||
<p>Keys are issued by whoever operates this gateway. If you do not know who that
|
||||
is, the address you reached this page at is the place to start asking.</p>
|
||||
{{end}}
|
||||
<p>A key is shown once and never again — only its hash is kept here — so put it in
|
||||
a password manager straight away.</p>
|
||||
reply = client.chat.completions.create(
|
||||
model="<model-name>",
|
||||
messages=[{"role": "user", "content": "hello"}],
|
||||
)
|
||||
print(reply.choices[0].message.content)</code></pre>
|
||||
|
||||
{{if .Notice}}<p class="note">{{.Notice}}</p>{{end}}
|
||||
<pre class="panel"><code>// ~/.config/opencode/opencode.json
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"llmgw": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "llmgw",
|
||||
"options": {
|
||||
"baseURL": "{{.BaseURL}}/v1",
|
||||
"apiKey": "{env:LLMGW_API_KEY}"
|
||||
},
|
||||
"models": { "<model-name>": { "name": "<model-name>" } }
|
||||
}
|
||||
}
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<p class="note">Anything that speaks the chat-completions API works, whether or not it
|
||||
is listed here — there is nothing llmgw-specific to install.</p>
|
||||
|
||||
<h2>Once you have one</h2>
|
||||
<ul>
|
||||
<li><code>GET {{.BaseURL}}/v1/models</code> — what your key may use</li>
|
||||
<li><code>GET {{.BaseURL}}/me</code> — its limits, and what it has spent</li>
|
||||
<h2>Once you have a key</h2>
|
||||
<ul class="endpoints">
|
||||
<li><code>GET {{.BaseURL}}/v1/models</code><span>what your key may use</span></li>
|
||||
<li><code>GET {{.BaseURL}}/me</code><span>its limits, and what it has spent</span></li>
|
||||
</ul>
|
||||
|
||||
<footer><span>llmgw {{.Version}}</span><span>{{.Now}}</span></footer>
|
||||
</div></body></html>{{end}}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Vanilla and inline, for the same reason this page has no build step. It is an
|
||||
// enhancement: the button only exists where the clipboard API does, so nothing
|
||||
// here can leave a dead control on the page.
|
||||
if (navigator.clipboard) {
|
||||
for (const pre of document.querySelectorAll('pre')) {
|
||||
// Read the text before the button joins the element, or "copy" ends up in
|
||||
// everything anyone pastes.
|
||||
const text = (pre.querySelector('code') || pre).textContent;
|
||||
const b = document.createElement('button');
|
||||
b.type = 'button';
|
||||
b.className = 'copy';
|
||||
b.textContent = 'copy';
|
||||
b.addEventListener('click', () => {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
b.textContent = 'copied';
|
||||
setTimeout(() => { b.textContent = 'copy'; }, 1200);
|
||||
});
|
||||
});
|
||||
pre.appendChild(b);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body></html>{{end}}
|
||||
@@ -559,3 +559,46 @@ func (brokenUsage) UsageByModel(context.Context, time.Time) ([]store.ModelUsage,
|
||||
}
|
||||
|
||||
var errUsage = errors.New("the database is unhappy")
|
||||
|
||||
func TestEveryClientExampleIsInThePageItself(t *testing.T) {
|
||||
// The tabs are radio buttons and a stylesheet, nothing more. If a panel were
|
||||
// fetched when its tab was picked, a reader with no JavaScript would choose
|
||||
// a tab and get an empty box — and this is the page people arrive on before
|
||||
// they have any reason to trust the site enough to enable anything.
|
||||
_, body := get(t, Landing("v1", true, false, "", ""), "http://llmgw.example/", nil)
|
||||
for _, want := range []string{
|
||||
"curl http://llmgw.example/v1/chat/completions",
|
||||
`base_url="http://llmgw.example/v1"`,
|
||||
`"baseURL": "http://llmgw.example/v1"`,
|
||||
} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("the page does not carry %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHostileForwardedHostCannotWriteMarkup(t *testing.T) {
|
||||
// Nothing overwrites X-Forwarded-Host when the gateway is reached directly,
|
||||
// so its value is whatever the caller sent, and it is now reflected into
|
||||
// several places on the page rather than one. Escaping is the template's
|
||||
// job; this is what says so out loud, and what would fail if any of those
|
||||
// places ever stopped being one.
|
||||
_, body := get(t, Landing("v1", true, false, "", ""), "http://internal/", map[string]string{
|
||||
"X-Forwarded-Host": `evil"><script>alert(1)</script><x y="`,
|
||||
})
|
||||
if strings.Contains(body, "<script>alert(1)</script>") {
|
||||
t.Error("a forwarded host reached the page as markup")
|
||||
}
|
||||
if !strings.Contains(body, "evil") {
|
||||
t.Error("the host was dropped rather than escaped, so the test proves nothing")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheLandingPageDiagramDescribesItself(t *testing.T) {
|
||||
// It carries the one idea the prose does not: that fabrics are separate. A
|
||||
// reader using a screen reader gets that from the label or not at all.
|
||||
_, body := get(t, Landing("v1", true, false, "", ""), "http://x/", nil)
|
||||
if !strings.Contains(body, `role="img"`) || !strings.Contains(body, "aria-label=") {
|
||||
t.Error("the schematic is decoration to anyone not looking at it")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user