From ce9b2aa5143bb39259eb43648c04ed238b96743e Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 1 Dec 2026 21:48:58 -0700 Subject: [PATCH] Add PLAN.md (open items) and TEST.md (manual test checklist) PLAN.md lists outstanding work: data accuracy checks, pricing and latency coverage, features not yet built, security hardening before internet exposure, and automated tests/CI. TEST.md is a browser and API (curl) checklist with expected results. Co-Authored-By: Claude Opus 5.5 --- PLAN.md | 84 ++++++++++++++++++ TEST.md | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 346 insertions(+) create mode 100644 PLAN.md create mode 100644 TEST.md diff --git a/PLAN.md b/PLAN.md new file mode 100644 index 0000000..48980ca --- /dev/null +++ b/PLAN.md @@ -0,0 +1,84 @@ +# Coremarket: open items + +Status as of 2026-12-01. The app works end to end. These are the things still to do, roughly in priority +order. + +## 1. Right now + +- [ ] **First push to Gitea.** `origin` is `https://gitea.federated.computer/david/coremarket.git`. + Run `git push -u origin main` and sign in with your Gitea username and a password or access token. +- [ ] **Commit `PLAN.md` and `TEST.md`**, then push. +- [ ] **Restart the container on the new build** with `ADMIN_USERNAME` / `ADMIN_PASSWORD` in `.env`: + `docker compose up -d --build`. Then work through `TEST.md`. + +## 2. Data accuracy (verify before quoting customers) + +- [ ] **Contabo surcharges outside the EU.** North America East is 0%, from your price table. UK 10%, + US Central/West 20%, Asia 35–40% and Sydney 45% are estimates. Check them in Contabo's order + page and enter them under **Edit Contabo prices**. +- [ ] **Contabo setup fee for the larger plans.** €2.00 is confirmed only for Cloud VPS 4. +- [ ] **Low-confidence prices:** HostAfrica (estimated from ZAR prices), Alibaba Cloud, and Hostinger + (24-month promotional rates; renewals are roughly double). +- [ ] **Medium-confidence prices:** OVHcloud, Scaleway, Hetzner (EUR converted at 1.16), Google Cloud and + Oracle regional multipliers, and AWS regional multipliers. +- [ ] **Compliance:** confirm each provider's HIPAA/SOC 2/PCI/GDPR scope covers the compute product + quoted. For example, OVHcloud's certifications cover Hosted Private Cloud, not VPS. +- [ ] **Calibrate sizing against real Federated installs.** App resource profiles are engineering + estimates. Coremarket sizes Base at 90 GB of disk, but Federated sells Base with 30 GB. Measure + RAM, CPU and disk on real Base/Good/Better/Best servers and update `app/data/software.py`. +- [ ] **Live exchange rate.** EUR→USD is fixed at 1.16 (`EUR_USD`). Consider fetching the ECB rate daily. + +## 3. Pricing coverage + +- [ ] **Live AWS pricing** via the AWS Price List API (needs AWS credentials). +- [ ] **Live Google Cloud pricing** via the Cloud Billing Catalog API (needs an API key). +- [ ] **Live OVHcloud pricing** via its public order catalogue API (`/order/catalog/public`). +- [ ] **Live Scaleway pricing** via its instance types API. +- [ ] **DigitalOcean and Hetzner live pricing** already work once `DIGITALOCEAN_TOKEN` / `HCLOUD_TOKEN` are + set. Create read-only tokens. +- [ ] **Regions near the uncovered cities:** Lagos, Cairo, Lima, Buenos Aires, Dhaka and Perth have no + nearby region in the catalogue. Shanghai is covered only by Alibaba's mainland regions, which + need an ICP licence. Candidates to research: Huawei Cloud (Latin America and Africa) and local + African hosts. + +## 4. Features suggested earlier, not built yet + +- [ ] Backup and snapshot pricing per provider. +- [ ] 1–3 year commitment prices (AWS, Azure, Google Cloud, Oracle save 30–60%). +- [ ] VAT and sales tax by country. +- [ ] Data sovereignty flags (e.g. US-owned providers under the CLOUD Act, even in EU regions). +- [ ] SLA (uptime guarantee) and support tier per provider. +- [ ] GPU options for local AI (Jupyter, Hermes). +- [ ] More certifications: ISO 27001, C5, HDS, FedRAMP. + +## 5. Latency + +- [ ] **Real measurements cover only some providers.** Only AWS, Hetzner and OVHcloud publish probe + hosts that answer; the DigitalOcean and Linode hosts were removed because they don't. Option: run + tiny probe targets in other providers' regions. +- [ ] **Store measured results** and show them in place of estimates where available. +- [ ] **Set `GLOBALPING_TOKEN`** for a higher measurement limit. + +## 6. Security and operations (before exposing to the internet) + +- [ ] **HTTPS:** put Coremarket behind a reverse proxy with TLS (e.g. Traefik or Caddy) and set + `COOKIE_SECURE=1`. +- [ ] **Client IP behind a proxy.** Sign-in throttling uses the client IP. Behind a proxy every request + appears to come from the proxy, so one attacker could lock out a username for everyone. Run uvicorn + with `--proxy-headers --forwarded-allow-ips=`. +- [ ] **Throttling is in memory,** so it resets on restart. Acceptable for now; store it if needed. +- [ ] **Audit log of admin actions:** accounts created or deleted, role changes, keys created or + revoked, price edits. +- [ ] **Session management:** let users see and sign out their other sessions. +- [ ] **Admin recovery command:** a way to reset an admin password without deleting + `/data/coremarket.db` (which removes all accounts). +- [ ] **Backups** of the `coremarket-data` volume (accounts, keys, Contabo sheet). +- [ ] **Pin the Docker base image** by digest, and update dependencies regularly. + +## 7. Engineering + +- [ ] **Automated tests.** There are none yet; everything was tested by hand and with scripts. Add a + pytest suite covering sizing (`engine.py`), the API (`api.py`, `accounts_api.py`) and auth + (`auth.py`), plus a Playwright browser smoke test. +- [ ] **CI in Gitea Actions:** run the tests and build the Docker image on every push. +- [ ] **Release tags and a changelog** once the first version is in use. diff --git a/TEST.md b/TEST.md new file mode 100644 index 0000000..aa9e359 --- /dev/null +++ b/TEST.md @@ -0,0 +1,262 @@ +# Coremarket: manual test checklist + +Work through these after each deployment. Tick each box when the result matches **Expect**. + +Some expected values depend on prices, which change when live prices refresh. Those say "about" or +describe a pattern instead of an exact figure. Sizing figures use the default workload: 5 concurrent +users, 10 named users, 25% headroom, 30% disk growth. + +## 0. Setup + +```bash +cd ~/Projects/coremarket +cp .env.example .env # set ADMIN_USERNAME and ADMIN_PASSWORD (10+ characters) +docker compose up -d --build +docker compose logs | grep -i admin +``` + +- [ ] **0.1** The logs show `created admin account ''` on the first start. +- [ ] **0.2** Temporarily remove both `ADMIN_*` lines from `.env`, delete the volume + (`docker compose down -v`), and start again. **Expect:** the container won't start, and + `docker compose logs` shows "First run: no accounts exist. Set ADMIN_USERNAME and ADMIN_PASSWORD…". + Put the lines back and start again. +- [ ] **0.3** With accounts existing, change `ADMIN_PASSWORD` in `.env` and restart. **Expect:** the log + says the variables are ignored, and the old password still works. + +--- + +## Part A: Browser + +Open http://localhost:8080. + +### A1. Sign-in + +- [ ] **A1.1** Opening `/` while signed out redirects to `/login`. +- [ ] **A1.2** A wrong password shows "Invalid username or password". +- [ ] **A1.3** Five wrong passwords in a row, then a sixth attempt. **Expect:** "too many failed + sign-in attempts; try again in … s". +- [ ] **A1.4** The correct password (after the lock expires, or from another browser) opens the app. + The header shows ` ▾`, **Edit Contabo prices** and **Refresh live prices**. +- [ ] **A1.5** Opening http://localhost:8080/docs while signed in shows the Swagger API docs. Signed out, + it redirects to `/login`. + +### A2. Software tiers and sizing + +- [ ] **A2.1** The **Federated tier** dropdown lists: Custom selection, Base · 2 apps · $19/mo, + Good · 11 apps · $70/mo, Better · 18 apps · $145/mo, Best · 22 apps · $290/mo. +- [ ] **A2.2** "Always included" shows **Traefik, Authelia, PowerDNS**. +- [ ] **A2.3** Pick each tier. **Expect** vCPU / RAM GB / Disk GB: + Base **2 / 5 / 90**, Good **4 / 12 / 270**, Better **6 / 21 / 340**, Best **6 / 26 / 380**. +- [ ] **A2.4** With Base selected, the Compare line reads "Federated Base hosted by Federated is + $19/mo (30 GB storage, managed, backups included)". +- [ ] **A2.5** Tick an extra app (e.g. Vaultwarden). **Expect:** the dropdown changes to "Custom + selection", and the Compare line disappears. +- [ ] **A2.6** **Clear** unticks every app. +- [ ] **A2.7** Set Concurrent users to 50. **Expect:** vCPU and RAM go up, and results update. +- [ ] **A2.8** Type 8 into the vCPU override box. **Expect:** every quoted plan has at least 8 vCPU. +- [ ] **A2.9** With Good selected, an amber note warns that the email server needs outbound TCP 25. + +### A3. Results and filters + +- [ ] **A3.1** **Prices by region** shows sections for North America, Europe, Asia, Australia, Africa + and South America, each saying "from $X first month". +- [ ] **A3.2** Click the **HIPAA** chip. **Expect:** only AWS, Azure, Google Cloud, Oracle and + DigitalOcean remain. +- [ ] **A3.3** Also tick "accept partial". **Expect:** Vultr, Akamai/Linode, Alibaba and OVHcloud reappear. +- [ ] **A3.4** Tick "exclude clouds that hard-block SMTP port 25". **Expect:** Azure, Google Cloud, + DigitalOcean and Alibaba disappear. Providers marked "on request" or "open" stay. +- [ ] **A3.5** Click the **South America** chip only. Select Bogota and Lima as focus cities, and set Max + RTT to 60. **Expect:** the remaining options have a worst RTT of 60 or less. Oracle Bogota should be + among them. +- [ ] **A3.6** Click a column header (e.g. **Total**) twice. **Expect:** the sort direction flips. +- [ ] **A3.7** **All options** shows every region. **Latency matrix** shows coloured RTT cells for 40 cities. +- [ ] **A3.8** **Export CSV** downloads `coremarket-YYYY-MM-DD.csv`. It has one row per option and + columns `rtt_ms_` for all 40 cities. + +### A4. VM detail window + +- [ ] **A4.1** Click a row. A detail window opens with **Close** at the top right *and* at the bottom. + Both close it, and so does Esc. +- [ ] **A4.2** For a Contabo row, the price line reads "… = $X/month + $2.32 one-time setup = $Y first + month". +- [ ] **A4.3** "Next-best plans in this region" lists up to 4 alternatives. +- [ ] **A4.4** Open an **AWS** or **Hetzner** row and click **measure** next to a nearby city. **Expect:** a + real RTT in ms with probe names. Example: Hetzner Ashburn → Washington DC is about 2 ms. +- [ ] **A4.5** Open a DigitalOcean or Contabo row. **Expect:** "No public probe endpoint is configured…" + and no measure buttons. + +### A5. Contabo price editor (admin) + +- [ ] **A5.1** **Edit Contabo prices** shows plans V153–V158 (Cloud VPS 4 to 18) in EUR, setup fee 2, + and region surcharges (us-east 0). +- [ ] **A5.2** Open **Paste a table** and paste: + ``` + | Code | Name | vCPU | RAM | Storage | Speed | Price/mo | + |------|------|------|-----|---------|-------|----------| + | V153 | Cloud VPS 4 | 4 | 8 GB | 100 GB SSD | 200 Mbit/s | €5.50 | + | V154 | Cloud VPS 6 | 6 | 12 GB | 200 GB SSD | 300 Mbit/s | €7.50 | + ``` + Click **Load pasted table**. **Expect:** "Loaded 2 plans (EUR)", and the plan table shows 2 rows. +- [ ] **A5.3** Set us-west's surcharge to 12 and click **Save prices**. **Expect:** the editor closes. Contabo + rows show "manual sheet " as the price source, and Seattle is 12% above New York. +- [ ] **A5.4** Restart the container (`docker compose restart`). **Expect:** the edits are still there. +- [ ] **A5.5** **Reset to built-in** and confirm. **Expect:** all 6 plans return, and the source says + "(defaults)". + +### A6. Live prices (admin) + +- [ ] **A6.1** **Refresh live prices**. **Expect:** after about 30–60 s, a summary shows `vultr: ok`, + `linode: ok`, `azure: ok`, with DigitalOcean/Hetzner "skipped (no API token configured)". The + header then shows "Live prices: Microsoft, Vultr, Akamai". + +### A7. Accounts (admin) + +- [ ] **A7.1** **Account ▾ → Users**. Create `alice` / `alice-password-1` / role `user`. **Expect:** + "Created account "alice"." and a new row. +- [ ] **A7.2** Try creating `alice` again. **Expect:** "username 'alice' already exists". +- [ ] **A7.3** Try a password of `short`. **Expect:** an error about at least 10 characters. +- [ ] **A7.4** On your own row there are no Disable/Delete buttons, and your role can't be changed. +- [ ] **A7.5** **Reset password** for alice and enter `alice-password-2`. **Expect:** "Password for alice + reset." + +### A8. API keys + +- [ ] **A8.1** **Account ▾ → API keys**. Create a key named "test", choosing alice in **For account**. + **Expect:** an amber box shows the full key (`cmk_…`) once, with a **Copy** button. Copy it for Part B. +- [ ] **A8.2** Tick "show every account's keys". **Expect:** the new key is still displayed, and the table + shows its account (alice). +- [ ] **A8.3** Close and reopen the dialog. **Expect:** the full key is no longer shown, only `cmk_xxxxxxxx_…`. + +### A9. Regular user + +Use a private window, or sign out first. + +- [ ] **A9.1** Sign in as `alice` / `alice-password-2`. **Expect:** no **Edit Contabo prices** or **Refresh + live prices** buttons, and no **Users** item in the account menu. +- [ ] **A9.2** The **Notes & API docs** tab has no "Edit prices" button. +- [ ] **A9.3** Quotes, tiers, filters, CSV export and measure all work. +- [ ] **A9.4** **API keys** lists only alice's keys, with no "show every account's keys" option. Create + one, then **Revoke** it. +- [ ] **A9.5** **Change password** with a wrong current password. **Expect:** "current password is + incorrect". Then use the right one. **Expect:** "Password changed." +- [ ] **A9.6** As admin, **Disable** alice. In alice's window, reload. **Expect:** back to the sign-in + page, and alice can't sign in. Re-enable her afterwards. +- [ ] **A9.7** **Sign out** returns to `/login`. Opening http://localhost:8080/ again redirects to `/login`. + +--- + +## Part B: API (curl) + +```bash +export BASE=http://localhost:8080/api/v1 +export KEY=cmk_... # alice's key from A8.1 (role: user) +export ADMIN_KEY=cmk_... # create one for yourself under Account → API keys +code() { curl -s -o /dev/null -w "%{http_code}\n" "$@"; } +``` + +### B1. Authentication + +- [ ] **B1.1** `code $BASE/tiers` → **401** (no key). +- [ ] **B1.2** `code -H "X-API-Key: $KEY" $BASE/tiers` → **200**. +- [ ] **B1.3** `code -H "Authorization: Bearer $KEY" $BASE/tiers` → **200**. +- [ ] **B1.4** `code -H "X-API-Key: cmk_deadbeef_nope" $BASE/tiers` → **401**. +- [ ] **B1.5** `curl -s -H "X-API-Key: $KEY" $BASE/auth/me` → `"username": "alice", "role": "user", "auth": "api_key"`. +- [ ] **B1.6** `code http://localhost:8080/healthz` → **200** without a key. +- [ ] **B1.7** `code http://localhost:8080/openapi.json` → **401**. With `-H "X-API-Key: $KEY"` → **200**. + +### B2. Reference data + +- [ ] **B2.1** `curl -s -H "X-API-Key: $KEY" $BASE/tiers` → 4 tiers. Base has `federated_price_usd_mo: 19` + and `federated_storage_gb: 30`. +- [ ] **B2.2** `curl -s -H "X-API-Key: $KEY" "$BASE/apps?tier=core"` → traefik, authelia, powerdns. +- [ ] **B2.3** `curl -s -H "X-API-Key: $KEY" $BASE/providers | grep -o '"id":"[a-z]*"'` → 14 providers. +- [ ] **B2.4** `curl -s -H "X-API-Key: $KEY" "$BASE/regions?continent=south-america&provider=oci"` → + Oracle regions incl. `sa-bogota-1`. +- [ ] **B2.5** `code -H "X-API-Key: $KEY" $BASE/apps/nope` → **404**. + +### B3. Sizing and quotes + +- [ ] **B3.1** Size Base plus Vaultwarden for 20 users: + ```bash + curl -s -H "X-API-Key: $KEY" -X POST $BASE/size -H 'Content-Type: application/json' \ + -d '{"tier":"base","apps":["vaultwarden"],"concurrent":20}' + ``` + **Expect:** `"need": {"vcpu": 3, "ram_gb": 7, "disk_gb": 90, …}`. +- [ ] **B3.2** Quote with filters: + ```bash + curl -s -H "X-API-Key: $KEY" "$BASE/quote?tier=good&continent=europe&compliance=gdpr&cities=par,ber&best_per_provider=true&limit=5" + ``` + **Expect:** `returned: 5`, one result per provider, each with `rtt_avg_ms` / `rtt_max_ms`, and all with + `compliance.gdpr` = `yes`. +- [ ] **B3.3** `…/quote?tier=best&compliance=hipaa&cities=bog,lim&sort=rtt_max_ms&limit=3` → Oracle + Bogota first. +- [ ] **B3.4** `…/quote?apps=nextcloud&vcpu=8&ram_gb=32&limit=1` → `need.vcpu` 8, `need.ram_gb` 32. +- [ ] **B3.5** `curl -s -H "X-API-Key: $KEY" -o q.csv "$BASE/quote?tier=better&format=csv"` → a CSV + with a header row and one row per region (about 250). +- [ ] **B3.6** Invalid input returns **422** with a helpful message: + `tier=gold`, `apps=foo`, `continent=mars`, `compliance=iso`, `provider=ibm`, `cities=xyz`. + +### B4. Roles + +- [ ] **B4.1** `code -H "X-API-Key: $KEY" $BASE/users` → **403** (user key). +- [ ] **B4.2** `code -H "X-API-Key: $KEY" -X POST $BASE/prices/refresh` → **403**. +- [ ] **B4.3** `code -H "X-API-Key: $KEY" -X DELETE $BASE/providers/contabo/price-sheet` → **403**. +- [ ] **B4.4** `code -H "X-API-Key: $ADMIN_KEY" $BASE/users` → **200**. +- [ ] **B4.5** A user can't create a key for someone else: + `code -H "X-API-Key: $KEY" -X POST $BASE/keys -H 'Content-Type: application/json' -d '{"name":"x","user_id":1}'` + → **403**. + +### B5. Account management with the admin key + +- [ ] **B5.1** Create bob: + `curl -s -H "X-API-Key: $ADMIN_KEY" -X POST $BASE/users -H 'Content-Type: application/json' -d '{"username":"bob","password":"bob-password-1"}'` + → **201** with bob's `id`. +- [ ] **B5.2** Create a 1-day key for bob (`"user_id": , "expires_days": 1`). **Expect:** the key + is in the response once, with `expires_at` about 24 h from now. +- [ ] **B5.3** Disable bob (`PATCH /users/` with `{"disabled": true}`). Bob's key → **401**. + Re-enable → **200** again. +- [ ] **B5.4** Delete bob. Bob's key → **401**. +- [ ] **B5.5** Last-admin safeguard: with only one admin, `PATCH /users/` with + `{"role":"user"}` → **409**. + +### B6. Browser-session protection (CSRF) + +- [ ] **B6.1** Sign in with curl and try a write without the `X-Coremarket` header: + ```bash + curl -s -c jar -X POST $BASE/auth/login -H 'Content-Type: application/json' \ + -d '{"username":"alice","password":"alice-password-2"}' + code -b jar -X POST $BASE/size -H 'Content-Type: application/json' -d '{"tier":"base"}' + ``` + **Expect:** **403** "missing x-coremarket header…". Add `-H 'X-Coremarket: 1'` → **200**. + +### B7. Latency measurement + +- [ ] **B7.1** + ```bash + curl -s -H "X-API-Key: $KEY" -X POST $BASE/latency/measure -H 'Content-Type: application/json' \ + -d '{"host":"ash-speed.hetzner.com","city":"was"}' + ``` + **Expect:** `probe_scope: "city"`, `min_ms` about 1–5, and probes in Washington. +- [ ] **B7.2** An unknown host (`"host":"example.com"`) → **422**. + +### B8. Price sheet (admin key) + +- [ ] **B8.1** `GET $BASE/providers/contabo/price-sheet` → `is_default: true` (after a reset). +- [ ] **B8.2** Use the README's `PUT` example with 2 plans. Then + `…/quote?provider=contabo&tier=base&limit=1` returns a plan from those 2. +- [ ] **B8.3** `DELETE` the sheet. `is_default` is `true` again. + +--- + +## Part C: Persistence and restart + +- [ ] **C1** `docker compose restart`. Accounts, API keys and Contabo edits remain. Browser sessions + survive, because they're stored in the database. +- [ ] **C2** `docker compose down && docker compose up -d` (without `-v`). The same applies. +- [ ] **C3** The cached live prices are still used after a restart. The header shows "Live prices: …" + without needing to refresh. + +## Report problems + +Note the test number, what you did, what you expected and what you saw. Include +`docker compose logs --tail 50` if the server returned an error (5xx).