Teams and keys¶
Every request to the farm carries an API key. A key belongs to one team. A team sees only its own sessions, recordings and apps, and can be limited in how many sessions it runs at once.
Teams¶
A team is a Team resource:
apiVersion: hearth.testzeus.com/v1alpha1
kind: Team
metadata:
name: checkout
namespace: hearth
spec:
maxSessions: 20 # 0 means no limit
admin: false # true: its keys can add and manage hosts (Macs)
Admin teams can manage the farm's device hosts (Add a Mac in two minutes); other teams
get 403 not_admin there. The chart's default team is an admin team.
With the chart, list teams in values; each gets a Team and a key:
teams:
- name: default
maxSessions: 0
- name: checkout
maxSessions: 20
- name: mobile
maxSessions: 5
Limits¶
maxSessions caps the sessions a team runs at once, across all pools: queued and running sessions
both count. When a team is at its limit, a new session is refused at once with HTTP 429,
Retry-After: 10 and the message your team is already running its limit of 20 sessions. The
slot comes back when a session ends.
GET /api/me (or hearth status) shows a team its own usage:
Not built yet
Restricting a team to some pools (Team.spec.pools) and reserving devices for a team
(Team.spec.reserved) are planned. Today every team can use every pool.
Keys¶
A key is a Secret in the farm's namespace, labelled with its team, holding the key in data.key:
apiVersion: v1
kind: Secret
metadata:
name: hearth-key-checkout
namespace: hearth
labels:
hearth.testzeus.com/team: checkout
stringData:
key: hth_...
- The operator reads every Secret with the
hearth.testzeus.com/teamlabel every 3 seconds and publishes the SHA-256 of each key to Redis. The gateway compares hashes; plain keys never reach Redis. - A team can have several keys: add more Secrets with the same label. That is how you rotate: add the new key, move your CI to it, delete the old Secret. A deleted key stops working within seconds.
- Any string works as a key. Use a long random one; the chart makes
hth_followed by 64 random lowercase letters and digits.
Keys from the chart¶
For each team in values, the chart creates <release>-key-<team>:
- With
key: ""(the default) a key is generated on first install and kept on every upgrade. - With
key: <value>the chart uses your value, which must be at least 32 characters. Prefer creating the Secret yourself (or with an external secret manager) over putting keys in a values file. - These Secrets carry
helm.sh/resource-policy: keep, so uninstalling the chart leaves them and a reinstall keeps the same keys.
Make a key by hand¶
kubectl -n hearth create secret generic hearth-key-checkout-ci \
--from-literal=key="hth_$(openssl rand -hex 32)"
kubectl -n hearth label secret hearth-key-checkout-ci hearth.testzeus.com/team=checkout
A Secret labelled for a team that has no Team resource still works; the team just has no limit.
(If you delete a Team whose keys you keep, its last published limit stays in effect until Redis
restarts. Set maxSessions: 0 before deleting it if that matters.)
Read a key: hearth key¶
hearth key # the "default" team's key
hearth key checkout # another team
hearth key checkout -n my-namespace
It reads the Secret hearth-key-<team> with kubectl, so it assumes the release is named
hearth. With another release name, read the Secret directly:
Not built yet
hearth keys create (making a key from the CLI) is planned. Use kubectl as above.
Where a key can go¶
| Where | Example | Used by |
|---|---|---|
| Bearer token | Authorization: Bearer hth_... |
Any HTTP client, Playwright headers |
| Basic-auth password | http://hearth:hth_...@farm/wd/hub |
Selenium, Appium (user name ignored) |
| Header | x-hearth-key: hth_... |
Anything that can set headers |
| Query parameter | ?token=hth_... |
Playwright clients that can only set a URL |
A key in a URL can end up in logs. Prefer a header when your client allows it.
In the web UI, you sign in with a key once and get a 12-hour cookie; see The web UI.
What a team can see¶
Every API route is scoped to the caller's team. A session, artifact or app of another team answers
404, exactly like one that does not exist.