Files
davidandClaude Opus 5.5 ef4bd67139 Skill consistency pass; pick -N releases from a repository
coreapp install <url> without a tag and coreapp update now count -N tags
(v6.2.0-1) as releases, the same rule as the version ordering.

Skill and README: a new account's first sign-in is repeated by deleting
the user in the app; deploy and publish build the Dockerfile, not the
Core; health paths should answer 2xx; the right cross-reference for
waiting at startup; the update log's name; a description that covers
mysql, mail, updating and publishing; updating.md and --form in README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 14:10:30 -07:00

704 lines
40 KiB
Markdown

# Testing
Manual checks for coreapp-dev. The scripts call `sudo`, `pacman`/`yay`,
`systemctl` and `virsh`, so they change the real system even when `HOME` is
a temporary folder. Run these on a machine or VM you don't mind changing.
## Static checks
```bash
cd ~/Projects/coreapp-dev
for f in install.sh update.sh uninstall.sh bin/coreapp-vm bin/coreapp libvirt/network-hook.sh; do bash -n "$f"; done
shellcheck -x install.sh update.sh uninstall.sh bin/coreapp-vm bin/coreapp libvirt/network-hook.sh
python3 -m py_compile core/coreapps lib/signin.py && rm -rf core/__pycache__ lib/__pycache__
```
## install.sh
1. If the system was last upgraded more than a day ago, `bash install.sh`
says so and runs `update` first (pacman's lists would otherwise name
versions the mirrors have deleted: 404s). Under `update` itself
(`COREDESKTOP_ALLOW_PACMAN=1`) it doesn't.
2. `bash install.sh`. It should:
- install whichever of `libvirt qemu-base virt-install dnsmasq edk2-ovmf
dmidecode` are missing
- enable and start `libvirtd.service`
- add you to the `libvirt` group
- define the `default` network if it's missing, set it to start at boot,
and start it
- print "coreapp-dev installed.", and the log-out note if your group
membership is new
3. Log out and back in, then check:
```bash
id -nG | grep -w libvirt
systemctl is-active libvirtd
virsh -c qemu:///system net-info default # Active: yes, Autostart: yes
ls ~/.local/share/coreapp-dev/images
```
4. Run `bash install.sh` again. It must succeed, print "already enabled" and
change nothing.
5. Error paths:
- With CoreDesktop missing: `HOME=$(mktemp -d) bash install.sh` should say
it needs CoreDesktop and exit 1.
## update.sh
1. `bash update.sh` with everything already installed: no package installs,
no prompts apart from sudo, exits 0.
2. Stop the network (`virsh -c qemu:///system net-destroy default`) and run
`bash update.sh`: it should start the network again.
## Through CoreDesktop's sibling command
Once the repo is in git:
```bash
export HOME="$(mktemp -d)"
mkdir -p "$HOME/.local/share"
ln -s ~/.local/share/coredesktop "$HOME/.local/share/coredesktop"
bash "$HOME/.local/share/coredesktop/sibling" add ~/Projects/coreapp-dev
bash "$HOME/.local/share/coredesktop/sibling" update
bash "$HOME/.local/share/coredesktop/sibling" add ~/Projects/coreapp-dev # re-run is safe
```
## The coreapp network
After `bash update.sh`:
```bash
virsh -c qemu:///system net-info coreapp # Active: yes, Autostart: yes
sudo ls -l /etc/libvirt/hooks/network.d/coreapp-dev
sudo nft list table ip coreapp-dev # masquerade for 10.123.0.0/24
sudo iptables -S | grep coreapp-dev # 3 INPUT and 2 FORWARD accepts
grep virbr-coreapp /etc/ufw/user.rules # DHCP, DNS, route rules
```
- Run `bash update.sh` again: no changes, and no ufw rules added twice. (This
also checks that the `grep` patterns match how ufw writes its rules; if one
doesn't, `update` asks for sudo every time.)
- `virsh -c qemu:///system net-destroy coreapp`: the nft table and iptables
rules are gone. `net-start coreapp`: they're back.
- The hook on its own, in a throwaway namespace (no host changes):
```bash
docker run --rm --cap-add NET_ADMIN -v "$PWD/libvirt/network-hook.sh:/hook:ro" \
--entrypoint bash corerelay:local -c \
'/hook coreapp started; /hook coreapp started; iptables -S | grep -c coreapp-dev; /hook coreapp stopped; iptables -S | grep -c coreapp-dev'
```
prints 5, then 0 (the `sysctl` error is expected inside a container).
- Moving from the old network (192.168.123.0/24): with a VM running,
`bash update.sh` redefines `coreapp` but doesn't restart it, and says how.
With no VM running, it restarts it: `net-dumpxml coreapp` shows
`10.123.0.1` and the `dhcp-host=52:54:00:c0:4e:10,...` option, and
`sudo iptables -S | grep -c 192.168.123` prints 0.
- The reservation works: `virsh -c qemu:///system net-dhcp-leases coreapp`
lists `coreserver` at `10.123.0.10`. (dnsmasq still logs "cannot read
.../coreapp.hostsfile": that file is libvirt's, root-only and now empty.)
- From the workstation, the Core's own services answer directly (its
containers are on 192.168.0.0/16, so this fails if the VM network is in
192.168.x.x):
`curl -sk -o /dev/null -w '%{http_code}\n' --resolve nextcloud.<domain>:443:10.123.0.10 https://nextcloud.<domain>/`
prints 302.
## CoreServer VM
1. Put Federated's dashboard key in `~/.config/coreapp-dev/authorized_keys`.
2. `coreapp-vm create`. Without the image, it downloads it first (1.3 GB;
interrupt it and run again: it resumes) and checks its SHA-256. It says
how many root keys it's installing (2: coreapp-dev's and the dashboard's)
and prints `IP: 10.123.0.10` within about two minutes.
3. `coreapp-vm list`: `coreserver` is running at 10.123.0.10.
4. `coreapp-vm ssh` logs in (after cloud-init, a minute later). Inside the VM:
- `cat /root/.ssh/authorized_keys` has both keys
- `df -h /federated` shows about 50 GB (the disk is 60 GB; `/` stays 10 GB)
- `ping -c3 1.1.1.1` and `getent hosts federated.computer` (internet and DNS)
- `systemctl is-enabled systemd-resolved` says `masked`
5. `coreapp-vm ssh hostname` prints `coreserver`; `coreapp-vm ip nope` says
there's no such VM.
6. `coreapp-vm create` again refuses with "already exists".
7. To see the screen: `virt-viewer -c qemu:///system coreserver`.
8. Once the Core is installed: `virsh -c qemu:///system reboot coreserver`.
Within a few minutes all its containers are up again, including `pdns`
(`dig +short A <domain> @10.123.0.10` answers).
9. `coreapp-vm stop`, then `coreapp-vm start`.
10. `coreapp-vm delete`: asks for the name; anything else keeps the VM. With
the name, the VM and `/var/lib/libvirt/images/coreserver.qcow2` are gone,
the image in `~/.local/share/coreapp-dev/images/` stays.
## Uninstall
On a machine you can rebuild (it removes the network every VM uses):
1. `bash uninstall.sh` with a VM on the `coreapp` network, answering no: it
stops, and nothing is removed.
2. Again, answering yes: the VMs and their disks are gone,
`virsh -c qemu:///system net-list --all` has no `coreapp`,
`/etc/libvirt/hooks/network.d/coreapp-dev` is gone,
`sudo iptables -S | grep -c coreapp-dev` prints 0,
`grep -c virbr-coreapp /etc/ufw/user.rules` prints 0 (virbr0's rules stay),
and `coreapp-vm` isn't on `PATH`.
3. Answering no to the data questions keeps `~/.local/share/coreapp-dev` and
`~/.config/coreapp-dev`.
4. `bash install.sh` puts everything back.
## The skill
1. After `bash update.sh`, `~/.claude/skills/coreapp` is a link to
`skills/coreapp` in the clone; running it again changes nothing. With a
real folder already at that path, it says so and leaves it.
2. `uninstall.sh` removes the link (only if it points at a
`skills/coreapp`).
3. Rehearsal: give an agent a small app with the usual problems (listens on
127.0.0.1, keeps its files next to the code, a hard-coded secret) and the
task "make it run on our Core as a Coreapp and test it". It should read
the skill, write `coreapp.toml` and a Dockerfile, move state to `/data`,
use `APP_SECRET`, deploy, check, and report what it couldn't test.
## The installer (coreapps), off the Core
`coreapps manifest <dir>` checks a `coreapp.toml` without a Core. With a
folder holding a valid one (`coreapp new x` makes one), each of these
changes is refused with a message saying what's allowed, and exit 1:
- `port = "8080"` (a string), `port = 0`
- `image = "coreapp/x"` (no registry, which would mean Docker Hub)
- `title = "A $(reboot)"`, a `description` with `"` or `` ` ``
- `name = "x-"`, `name = "X"`, `name = "mail"` (one of the Core's hostnames)
- an unknown setting (`extra = 1`), `needs = ["redis"]`
- a missing `version`
`needs = ["sso", "postgres"]` is accepted and printed in setup order
(`needs=postgres sso`). `coreapps plan <dir>` off the Core (not root) says
to run it as root on the Core.
## Apps (coreapp)
Against a Core in the VM (`coreapp-vm list` shows it running). These install
test apps on that Core. None may be registered with Federated's monitoring:
the generated `/federated/services/<name>/service` has no `MONITOR` line.
The Core's own scripts trace secrets, so their output goes to
`/federated/logs/coreapps/<name>-<install|update|remove>.log` on the Core
(folder mode 700, files 600), never to the terminal unless a step fails.
1. `cd $(mktemp -d) && coreapp new hello`: `./hello` has `coreapp.toml`,
`Dockerfile`, `.dockerignore`, `icon.png`, `www/`, `README.md` and
`.gitea/workflows/publish.yml`, and nothing else, with no placeholder
left (`grep -r '{{[A-Z]' hello` prints nothing; the workflow's
`${{ ... }}` are Gitea's). `coreapp new hello` again refuses; so does `coreapp new x-`.
2. `cd hello && coreapp deploy`: updates `/opt/coreapps` on the Core,
builds, copies the image, prints `Installing hello at 192.168.5.x`
(the first free address there) and `Installed: https://hello.<domain>/`.
On the Core, `/federated/services/hello/` has `service`,
`docker-compose.yml.in`, `env.in`, `install`, `uninstall`, `icon.png`,
`coreapp.toml` and `.coreapp` (`needs=`); `/federated/apps/hello/.env`
is root's, mode 600, with `IMAGE_VERSION` equal to `version` and a
random `APP_SECRET`, `CORE_DOMAIN` the Core's domain and
`CORE_ADMIN_EMAIL` `admin@<domain>`, `CORE_PROXY` traefik's address (as
`INTERNAL_IP` in `/federated/services/traefik/service`) (an app installed
before they existed gets them on its next update).
Superpanel's catalog
(`/federated/apps/superpanel/data/catalog.json`) lists `hello`.
3. `coreapp check`: `OK: HTTP 200, valid certificate.` (the first
certificate can take a minute).
4. Change `www/index.html`, `coreapp deploy`: "Updating hello to 0.1.0",
the container is recreated, the page shows the change, `.env` is
unchanged. `coreapp deploy` again: "The Core already has this image.",
and the container is the same (`docker inspect -f '{{.Created}}'`);
`coreapp deploy --recreate`: "Updating hello (0.1.0 again, in a new
container)...", a new container, same data.
5. Raise `version` to 0.2.0, `coreapp deploy`: "Updated"; the container
runs `:0.2.0`; `docker image ls localhost/coreapp/hello` on the Core lists
only 0.2.0.
5a. Right after "Updated" (also with `--recreate`), the public address
answers (deploy waits until traefik routes it, not 404): `curl
https://<name>.<domain><health>` four times in a row gives 200 each time.
An app that answers 421 to an unknown `Host` (Supermarket): deploy's
wait passes because it sends `Host: <name>.<domain>`; on the Core, curl
of its health URL gives 421 bare, 200 with that `Host`.
5b. `coreapp core` (anywhere, no app needed): the domain, PostgreSQL's
version, its extensions in two lists (pg_trgm in "the app can enable",
vector in "only the Core can enable"), MariaDB, Authelia, the mail
server, Traefik, Docker and Compose versions, the machine, the apps'
disk (btrfs) and what's not offered. As an app's database user,
`CREATE EXTENSION pg_trgm` works and `CREATE EXTENSION vector` is
refused ("Must be superuser").
5e. Names: `coreapp core` lists "Names apps can't use" (Federated's apps
from `/federated/services` and `/federated/lib`, installed or not, and
the Core's host names; not coreapps' own apps). Deploying `listmonk`:
"'listmonk' is the name of one of Federated's apps on this Core (not
installed, but the Core can install it) ..."; `nextcloud`: "...
(installed)"; `carpal` (only a script in `/federated/lib`): refused too.
An app coreapps installed (`listmonk-app`) deploys as before.
5c. `[postgres] extensions`: a `coreapp new --postgres` app with
`[postgres]` `extensions = ["vector"]` deploys with "Enabling PostgreSQL
extension(s) vector"; on the Core, its database has vector (owned by
postgres), and as the app's user a `vector(3)` table, a distance query
and an HNSW index work. Adding `"postgis"` is refused before anything
changes ("this Core's PostgreSQL doesn't have postgis"); adding
`"pg_trgm"` enables only that; `"earthdistance"` brings cube with it.
An update that fails (a wrong `port`) rolls back with the extensions,
the table and its index. `[postgres]` without `"postgres"` in needs, an
unknown setting or a bad name is refused; so is `needs` with both
postgres and mysql.
5d. `min_version`: on the Core's PostgreSQL 17.6, a new app with
`[postgres]` `min_version = "18"` is refused before anything is built
("Vectest needs PostgreSQL 18 or newer ...; this Core has 17.6");
`"17"` installs; raising it to `"18"` in an update is refused and the
app keeps running. A `--mysql` app with `[mysql]` `min_version = "13"`
is refused ("needs MariaDB 13 or newer ...; this Core has 12.1.2").
Comparison is numeric (`"17.10"` is newer than 17.6); `min_version =
17.4` (a TOML number with a dot) and `">=18"` are refused with a hint;
`[mysql]` has no `extensions`.
5f. An image with its own failing `HEALTHCHECK` (`coreapp new x`, then
`HEALTHCHECK --interval=3s --retries=2 CMD ["false"]` in the
Dockerfile): a new install stops with "Docker says x is unhealthy, so
traefik doesn't route ... (CMD false); its last result: exit code 1"
and "x is installed but not working. Deploying again updates it ...".
With a passing check (`wget -qO /dev/null http://127.0.0.1:8080/`) it
deploys; breaking it again in an update gives the same message with
the wget error, rolls back, and right after "Rolled back" the public
address answers 200 (the rollback waits for traefik).
5i. Versions from a folder: with `6.2.0` installed, deploying `6.1.9` is
refused before building ("has version 6.2.0 installed; 6.1.9 is
older ... add --downgrade"); `coreapp deploy --downgrade` deploys it;
`6.2.0-1` and the same `6.2.0` deploy without asking. Releases order
`v1.2.0` < `v1.2.0-2` < `v1.10.0`, and `coreapp install <url>` without
a tag (and `coreapp update`) picks `v6.2.0-1` over `v6.2.0`; tags like
`v6.2.0-rc1` aren't releases. `coreapp status` shows "This
folder: ..." and "Installed version: 6.2.0" from the Core.
5j. A container that fails to start (prints a line and exits): deploy
prints the end of its log and "Its whole log, from its first start:
/federated/logs/coreapps/<name>-failed-start.log", which has every
restart's lines with timestamps; the same after an unhealthy check.
5g. A slow start (`coreapp new slowtest`, with `CMD` sleeping 40 s,
logging "migrating", before the server): deploy prints "still starting
(31 s); its log: migrating", then "Installed". A container that exits
or restarts three times stops the wait at once with its state and log;
one that never answers stops after 5 minutes ("doesn't answer at ...
after 300 s").
5h. An image declaring `VOLUME /var/www/storage` (outside `/data`): deploy
prints "Note: the image declares VOLUME /var/www/storage ..." and
installs. `coreapp remove` removes its anonymous volume too (`docker
volume ls -q` shows none left; uninstall runs `down -v`).
6. `coreapp status` (address and port), `coreapp logs`, `coreapp shell`
(exit with `exit`), `coreapp shell 'id; echo $APP_URL'` (prints both,
no terminal needed, also when piped), `coreapp list` (all apps installed
by coreapps). With `/coreapp/env.sh` in the container (`export
CA_TEST=works`), `coreapp shell 'echo $CA_TEST'` and `echo $CA_TEST`
in an interactive `coreapp shell` print `works`; without the file,
nothing changes.
7. `coreapp remove`, answering y: on the Core, `/federated/apps/hello`,
`/federated/services/hello`, the container and the image are gone, and
the catalog no longer lists `hello`.
8. Refused, with nothing changed on the Core:
- `name = "nextcloud"` (one of Federated's apps) or `name = "mail"`
- `image = "localhost/coreapp/nope"` with no such image on the Core
(change `image`, and skip coreapp's build by running
`coreapp-vm ssh /opt/coreapps/coreapps install <dir>` on a copy)
- with the app installed with `needs = ["postgres"]`, deploying with
`needs = []` without `--drop-database` ("drops postgres: that deletes
...'s database ... add --drop-database"); with it, typing another name
at the question: "Not deployed; nothing changed."
8a. Dropping needs (an app from `coreapp new --postgres --sso --email`,
then given the template's static `Dockerfile` and `www/`, which need
nothing):
- `needs = ["postgres"]`, deploy: "no longer needs: sso email", then,
after the app answers, "Removing what it no longer needs from the
Core: sso, email..."; the Authelia block and the client's copy are
gone, Authelia healthy after its restart, the LDAP mail account gone,
no `OIDC_*` or `SMTP_*` in `.env`, the database kept.
- With the example's own code (which needs `OIDC_*`): the new version
doesn't start and the update rolls back; the needs, settings, client
and mail account are all still there.
- `needs = ["mysql"]`, `coreapp deploy --drop-database`, typing the name,
with a Dockerfile whose container exits: rolled back, the PostgreSQL
database still there. With the working Dockerfile: the PostgreSQL
database and user are gone, `.env` has `DB_HOST=pdnsmysql.<domain>`
and a new `DB_PASSWORD` that logs in to MariaDB.
- After a deploy whose health path answers 404 from the app itself, no
"traefik doesn't route" note (deploy compares traefik's answer with
the app's own).
9. `/data` is writable by the app: with an image that runs as `nobody`
(the `--postgres`/`--sso` examples), `coreapp shell` then
`touch /data/x` works; on the Core, `/federated/apps/<name>/data` belongs
to uid 65534.
10. A failed update rolls back. Note `md5sum` of the app's `.env`,
`docker-compose.yml`, `service` and `.coreapp` on the Core. Raise
`version`, set `port = 9999` (nothing answers there) and add `"postgres"`
to `needs`, then deploy: after "doesn't answer", "Rolling back" and
"Rolled back: hello 0.2.0 runs again"; deploy exits 1. The four files
are unchanged, the container runs the old tag and answers on its old
port, the new tag is gone from `docker image ls`, and `coreapp_hello`
isn't in PostgreSQL. With the same `version` (and `port = 9999`):
"Rolled back hello (its settings and /data as before the update). It's
the same image tag as before".
Data: an app with `needs = ["postgres"]` (then again with `["mysql"]`),
a table with a row "before" and `/data/file` with "before". Start a
failing update; once `/federated/apps/.coreapps-rollback-<name>-*/` has
`db.dump` (`db.sql`) and `data`, and the container runs the new tag,
change the row to "after", add a table and a file in `/data`. After
"Rolled back: ... with its settings, its database and /data as before
the update": the row says "before", the new table and file are gone,
the table's owner is the app's user, the app's user can still read it,
and no `.coreapps-rollback-*` folder is left. A successful update leaves
none either.
10a. Room for the database's copy (with `core/coreapps` loaded as a
module, only in the test): `database_size("postgres",
"coreapp_<name>")` and `database_size("mysql", "powerdns")` give sizes,
a missing database `None`. With `ROLLBACK_RESERVE` larger than the disk,
an update is refused: "keeps a copy of its database (... MB) until the
update has worked ... has ... GB free ... Nothing was changed", the
container isn't restarted and no `.coreapps-rollback-*` folder is left.
With `BIG_DATABASE = 0`: "Keeping a copy of its database (...) in case
the update fails; this takes a while...", then "Updated".
10b. Dump speed: an app whose database holds 1.3 GB (e.g. a table of 4.5
million rows with an index): `coreapp deploy --recreate` says it's
keeping a copy (above 1 GB) and the whole update takes under a minute;
the log on the Core shows no pg_dump error. A failing update (a wrong
`port`) rolls back with every row. In the module, a `DUMP` command that
fails with `-Z` is run again without it (the copy is kept, the error in
the log); one that always fails refuses the update.
11. Superpanel: after deploy, `/federated/apps/superpanel/data/applist.json`
(the dashboard) and `catalog.json` have the app; `service` has
`URL="https://hello.$DOMAIN/"` and applist the same `url`. Change
`title`, raise `version`, deploy: both files have the new title. After
`coreapp remove`, neither has it. An app installed from a repository
with no `docs` has `DOCS=<the repository>` in `service` and applist.
12. Icons: `python3 core/coreapps manifest .` prints `icon=` and
`icon_note=`: no `icon.png` "missing"; a link, a non-PNG, or one over
1 MB "bad" (with why); a PNG of 300x100 "ok" with a note to make it
square; 32x32 "ok" with a note that it's small; 256x256 and the
template's (128x128) "ok" with no note. Deploying with a non-PNG
`icon.png`: "Note: icon.png isn't a PNG, so the Core shows the default
icon instead." once, and the Core's `services/<name>/icon.png` is the
default. `coreapp publish` (in a git repository, `image` not
localhost/) refuses a non-PNG icon, and one in `.gitignore` ("isn't in
the repository"), before it looks at the registry.
13. On a Core whose tier isn't enterprise, deploying a new app asks before
it's recorded as an add-on; answering no deploys nothing.
### With a database
1. `coreapp new --postgres guest-book`: has `app.py`, no `www/`;
`coreapp.toml` has `needs = ["postgres"]` and `health = "/health"`; the
README has a Database section.
2. `coreapp deploy`, `coreapp check`. Loading the page several times
(`curl -s https://guest-book.<domain>/ | grep visits`) counts up. On the
Core, `docker exec postgresql psql -U postgres -l` lists `coreapp_guest_book`,
owned by `coreapp_guest_book`; `.env` has `DB_*`. `coreapp status`:
"The Core's PostgreSQL: 17.6" (`mysql` apps: "The Core's MariaDB:
12.1.2").
3. Change `app.py`, `coreapp deploy`: the change shows, the count continues.
4. `virsh -c qemu:///system reboot coreserver`: once the Core is up, the
app answers and the count continues (its log may show "Waiting for the
database" first).
5. `coreapp remove`: the `coreapp_guest_book` database and user are gone too.
Adding a need later: install `coreapp new notes` (no needs), then set
`needs = ["postgres"]` and deploy: "Updating", `.env` gains `DB_*` (the
other values unchanged), the database `coreapp_notes` exists, the container
has the `DB_*` variables, `.coreapp` says `needs=postgres`.
### With sign-in
1. `coreapp new --sso sso-demo`: has `app.py` and `oidc.py`, no `www/`;
`needs = ["sso"]`; the README has a Sign-in section.
2. `coreapp deploy`, `coreapp check`. On the Core, `idproviders.yml` has one
`### coreapp-sso-demo begin` block; Authelia is healthy;
`docker exec authelia authelia validate-config` is OK; no `*.bak` is
left; `/federated/apps/sso-demo/docker-compose.yml` maps
`authelia.<domain>` to traefik's address (`extra_hosts`).
3. `https://sso-demo.<domain>/login` redirects to
`https://authelia.<domain>/api/oidc/authorization?...client_id=coreapp-sso-demo...code_challenge_method=S256`.
4. In a browser, sign in with a Core account: the page says "Signed in as
..." with the account's email and groups. "Sign out" goes back to the
sign-in link.
`/federated/apps/sso-demo/.sso-demo.oidc-client.yml` (mode 600) holds
the same block.
5. The copy restores the client: delete the block from `idproviders.yml`
(keep a backup), run `/federated/bin/reconcile-authelia-sso`: it says
"Restoring sso-demo's Authelia OIDC client" and the block is back.
6. Redeploy: still one client block, and Authelia isn't restarted
(`docker inspect -f '{{.State.StartedAt}}' authelia` unchanged).
`coreapp remove`: no block and no copy, and running
`/federated/bin/reconcile-authelia-sso` doesn't bring it back; Authelia
healthy, other clients (Nextcloud) still work. Deploy again: one block.
7. `[sso]`: `coreapps manifest` prints `sso_callback`, `sso_pkce`,
`sso_token_auth` (defaults `/auth/callback`, `true`,
`client_secret_basic`). Refused: `[sso]` without "sso" in needs, a
callback that isn't a path (`auth`, `/a'b`), `pkce = "no"`, `token_auth =
"none"`, an unknown key, `sso = "x"`. With the defaults, the client
block is the same as before `[sso]` existed.
8. Add `[sso] token_auth = "client_secret_post"` to an installed app and
deploy: its block says `client_secret_post` and Authelia restarted and is
healthy; remove it, deploy: `client_secret_basic` again. `callback =
"/auth/openid/core"`, `pkce = false`: the block has that redirect URI,
`require_pkce: false` and no `pkce_challenge_method`; Authelia's
authorize URL with that `redirect_uri` goes to its login page, with
`/auth/callback` to an `invalid_request` error. The copy
(`.<name>.oidc-client.yml`) matches.
9. Stock Vikunja (`vikunja/vikunja:2.8.0` with a busybox entrypoint,
`[sso] callback = "/auth/openid/core"`, `pkce = false`): `/api/v1/info`
lists the "Federated Core" provider; a browser sign-in with a Core
account works. `coreapp signin --code` gives a code for
`/auth/openid/core`; `POST /api/v1/auth/openid/core/callback` with it
and `redirect_url` returns a token, and `/api/v1/user` with it is
`coreapp.test@<domain>`.
10. `coreapp signin` (sso-demo): prints each step (login, authorize,
Authelia's page, `POST /api/firstfactor -> 200 OK`, authorize again,
the callback, the app's page) with no code, state or flow_id values,
ends "Signed in: back at the app, ... HTTP 200" and "Its page shows
coreapp.test", exit 0. On the Core, LDAP has `uid=coreapp.test,ou=people`
(`inetOrgPerson`, description `coreapps: test account for coreapp
signin`); a second run sets a new password and reuses it. `--cookies
jar /login`, then `curl -b jar https://sso-demo.<domain>/`: "Signed in as
coreapp.test". `coreapp signin /nope`: "didn't lead to the Core's
sign-in", exit 1. `coreapp signin login` and in an app without "sso":
refused. `--code`: the callback URL, `code`, `state`, `code_verifier`
(PKCE apps only), exit 0. `lib/signin.py --code` with a callback the
client doesn't have: Authelia's `invalid_request` and the hint "The
'redirect_uri' parameter does not match", exit 1. A wrong password:
"Authelia refused the test account", exit 1 (no more than two: Authelia
bans after three). `coreapp signin --remove-account`: "Removed", then
"There's no test account"; `coreapp signin` makes it again.
`coreapps test-account` with less than 16 characters on stdin: refused.
11. A sign-in page with a button (Supermarket's `/signin`: a password
form, and a POST form to `/signin/core` with only hidden fields):
`coreapp signin /signin` shows `POST .../signin/core (the form's button
"Sign in with ...") -> 303`, then signs in. `--form /signin/core
/signin`: the same. `--form /nope /signin`: "has no form with action
/nope (its forms: /signin, /signin/core)". A page whose only link to
sign-in doesn't name Core SSO (sso-demo deployed before the label,
"Sign in with your Core account" at `/`): "didn't lead to the Core's
sign-in". A page with two hidden-only forms: "several forms ... pick
one with --form".
11b. A sign-in link: Leantime's `/auth/login` (a password form and a link
"Sign in with Core SSO" to `/oidc/login`): `coreapp signin
/auth/login` shows `GET .../oidc/login (the link "Sign in with Core
SSO") -> 302` and signs in. In the module, `pick_link` finds a link by
its text, title or aria-label (Core SSO or Authelia), follows two
links to the same address, and none when two name different ones.
`page_says` gives the text of elements whose class, id or role says
alert, error, notice and the like (`' The page says: "..."'`), and ''
without one; the "Not signed in" messages after the app end with it.
`coreapp signin --help` prints signin's part of `coreapp help`.
11a. A callback that fails quietly: an app whose callback sends the browser
back to its sign-in page (Miniflux with group mapping on, or its sign-in
page replayed through `signin.main` with `follow` replaced): "Not
signed in: Authelia accepted the test account, but the app ended at
..., which offers sign-in again", exit 1. A page that neither shows the
test account nor offers sign-in: "Signed in ..." and "Its page doesn't
show coreapp.test, but doesn't offer sign-in again either ...".
12. The Core's admin: a new `coreapp new --sso` app, deployed, `coreapp
signin --cookies jar`: its page says "Signed in as coreapp.test ...
groups: none." (not admin). With `CORE_ADMIN_EMAIL` in its `.env` set
to the test account's address in other capitals, recreated: "..., the
app's admin." In a browser as `admin@<domain>`: "the app's admin".
### With mysql
1. `needs = ["postgres", "mysql"]`: refused ("postgres or mysql, not
both"); `coreapp new --postgres --mysql x` too.
2. `coreapp new --mysql my-test`: `needs = ["mysql"]`, deploy. `.env` has
`DB_HOST=pdnsmysql.<domain>`, `DB_PORT=3306`, `DB_NAME` and `DB_USER`
`coreapp_my_test`, a random `DB_PASSWORD`; `service` has
`DEPENDS="pdnsmysql"`.
3. `docker run --rm --network core --env-file /federated/apps/my-test/.env
mariadb:12.1.2 sh -c 'mariadb -h$DB_HOST -u$DB_USER -p$DB_PASSWORD $DB_NAME ...'`:
create, insert, select work; `show databases` lists only its own;
`@@character_set_database` is `utf8mb4`; `powerdns` is denied (1044);
a wrong password is denied (1045).
4. The install log (`/federated/logs/coreapps/my-test-install.log`) has
root's password only on Federated's `MYSQL_ROOTPASSWORD=` lines.
5. `coreapp remove`: no `coreapp%` user or database left in MariaDB.
### With email
1. `coreapp new --email mail-test`: `needs = ["email"]`, deploy. On the
Core, `.env` has `SMTP_HOST=mail.<domain>`, `SMTP_PORT=587`,
`SMTP_SECURITY=starttls`, `SMTP_USER=coreapp-mail-test`, a random
`SMTP_PASSWORD`, `SMTP_FROM=mail-test@<domain>`; `service` has
`DEPENDS="mail"`; LDAP has `uid=coreapp-mail-test,ou=people,<base>` with
`objectClass` account, simpleSecurityObject, PostfixBookMailAccount (no
person), `mailEnabled: FALSE`, `description: coreapps: mail-test`, and
a `{SSHA}` password.
2. From a container on the `core` network with the app's `.env`
(`docker run --rm --network core --env-file /federated/apps/mail-test/.env ...`),
Python's `smtplib`: STARTTLS with certificate checking, login, `MAIL FROM`
`SMTP_FROM` and `RCPT TO postmaster@<domain>` both 250 (then `RSET`; nothing
sent). A wrong password: 535.
3. Authelia's `/api/firstfactor` as `coreapp-mail-test` with its real
password: 401. `occ user:list` in Nextcloud and Superpanel's
`user_store` (after `superpanel-sync-users`) don't have it.
4. `coreapp remove`: the LDAP entry is gone.
5. An LDAP entry `uid=coreapp-mail-test` that isn't the app's (another
`description`): deploy prints "Warning: mail-test can't send mail", the
entry is unchanged (its password too), and remove leaves it.
6. Adding `"email"` to an installed app's `needs` and deploying makes the
account and adds the `SMTP_*` settings.
7. `coreapp mail` after the app sent a message (Supermarket: a password
reset for `coreapp.test@<domain>`): "<time> from <name>@<domain>,
accepted", then "to coreapp.test@<domain>: sent", one line per message
even after retries. No mail in the last day: "has no mail from
<name>". In an app without "email": refused.
8. `coreapp inbox` (anywhere): the same reset is there, "From: Supermarket
<supermarket@<domain>>", its subject and text with the `/reset/...`
link. An HTML-only message shows as text, `Confirm
<https://...>` for a link, without its `<style>`; an encoded subject
(`=?utf-8?q?...`) is decoded, and so is a text/plain part that is
really HTML (Snipe-IT's reset mail). `--clear` says how many it removed, then
"inbox is empty". The test account's LDAP entry has
`PostfixBookMailAccount`, `extensibleObject`, `mailEnabled: TRUE` and
`homeDirectory: /home/coreapp.test` and no `uidNumber`; an entry made
before (without them) gets them on the next `coreapp signin` or
`coreapp inbox`, and mail deferred for it is then delivered. `coreapp
signin --remove-account` removes the entry and its maildir
(`/federated/apps/mail/data/var/mail/<domain>/coreapp.test`); `coreapp
inbox` makes both again. `coreapp signin` still signs in afterwards.
A message with `Reply-To` shows it under `From`; one the spam filter
filed in the test account's Junk folder (sent without `Date` and
`Message-ID`) is listed too, marked "(in Junk: ...)", and `--clear`
empties both.
9. An app that sends more than 2 messages within a minute: the third
gets `450 4.7.1 ... too much mail`, and `coreapp mail` lists it as
"refused: too much mail at once (temporary, 450)" in time order with
the accepted ones, then a line on the limit. Refusals of another app
(a name that ends the same) aren't listed.
### With both
1. `coreapp new --postgres --sso team-visits`: `needs = ["postgres",
"sso"]`; `app.py` imports `oidc` and `psycopg`.
2. `coreapp deploy`, `coreapp check`. On the Core, `service` has
`DEPENDS="postgresql authelia"`, `.env` has `DB_*` and `OIDC_*`. In a
browser, sign in: the page shows your name and "Your visits", which
counts up on reload. Another account gets its own count; "people who have
visited" counts both.
3. `coreapp remove`: the database, user and Authelia client are gone.
### Apps deployed before coreapp.toml
An app deployed by an older coreapp (its own `service`, `install`, ... and
an empty `.coreapp` marker on the Core) moves over by replacing those files
with a `coreapp.toml` with the same name, image and needs. `coreapp deploy`
then updates it: same address, `.env` and data unchanged, no needs set up
again (they're read from its `DEPENDS`), Authelia not restarted; `.coreapp`
then says which needs it has. Apps with an address outside 192.168.5.0/24
get a new one on their next update (the container moves; the app keeps
working), and apps with sign-in get their client copy.
## Installing from a repository (coreapp install, update)
Needs a public git repository over https whose release tag `v<version>`
has a `coreapp.toml` with a published, public `image` (e.g. after
`coreapp publish`).
1. `coreapp install https://<host>/<owner>/<repo>`: shows the title,
version, source with tag and commit, image, needs and URL, and asks.
Answering no installs nothing. Yes: "<title> <version> from <url>
(v<version>, commit ...)", "Pulling ...", "Installed: https://...".
`coreapp list` shows `<url>@v<version>`; on the Core,
`/federated/services/<name>/.coreapp` has `source`, `tag`, `commit`.
2. Publish a newer version, then `coreapp update <name>`: "Updated", the
old image is gone from the Core. Again: "at the newest release".
3. `coreapp install <url>@v<old version>` with a newer one installed:
"is older, and may not understand the data ... add --downgrade", nothing
changed. `coreapp install --downgrade <url>@v<old version>`: the plan
says "Goes back from the installed v<new>", then installs that tag; the
newer image is gone from the Core.
3a. Digest: after installing, "Image: <image>:<version>@sha256:..."; the
marker has `digest=`, the `.env` `IMAGE_DIGEST=@sha256:...`, `docker
compose config --images` and the container's image are
`<image>:<version>@sha256:...`. Push another image to the same tag, then
install that release again: "isn't the image installed here ... the
release was changed after it was published", the app keeps running,
`<image>:<version>` on the Core is the installed image again, and
`docker compose up --force-recreate` runs it. An app deployed from a
folder has `IMAGE_DIGEST=` (empty) and runs `<image>:<version>`.
(Tested with a registry on the Core, `docker run -p 127.0.0.1:5000:5000
registry:2`, `image = "localhost:5000/<name>"`, and a `file://`
repository as below.)
4. Refused with a message, nothing changed:
- a URL with a password (`https://u:p@host/o/r`), `http://`, `ssh://`,
or one level only (`https://host/repo`)
- a repository without `v1.2.3` tags (unless `@<tag>` is given), a tag
that doesn't exist, `@main`
- a tag whose `coreapp.toml` has another `version`
- `image = "localhost/..."` at the tag
- the same app name from another repository
- a private repository, or an image that can't be pulled
5. `icon.png` that's a symbolic link in the repository: the default icon is
used.
6. Private: with a private repository and package, `coreapp install <url>`
stops with "If it's private, give this Core a token for <host>: coreapp
login <host>". `coreapp login <host>` with a wrong token: "rejected the
token", nothing saved. With a read-only token (Gitea: repositories and
packages, read): "Saved a token ... (its registry accepts it)", then
`coreapp install <url>` works; `coreapp logins` lists the host (no
token shown); on the Core `/etc/coreapps` is 700, `credentials` 600, and
`/root/.docker/config.json` has no entry for the host. `coreapp logout
<host>`: installing fails again.
6b. `coreapps login <host> <user>` run at a terminal on the Core (`ssh
-tt`): it asks "Token for <user> on <host>: " and what's typed isn't
shown; a wrong token is rejected, nothing saved. Ctrl-D at the prompt:
"No token given. Nothing was saved." on its own line. Piped (`echo
<token> | coreapps login ...`, as `coreapp login` does): no prompt, the
same checks. `/etc/coreapps/credentials` unchanged after all three.
6a. Tokens per owner: `coreapp login <host>/<owner>` with a wrong token is
rejected, the file unchanged. With a token saved for `<host>/<owner>`
(on the Core, a wrong one written with `write_credentials`, to see which
is used), `coreapps plan https://<host>/<owner>/<repo>` uses it before
the host's: "Couldn't read ... (It used the token for <host>/<owner>:
check it can read this repository.)"; with one for another owner, the
host's token is used and the plan works. `coreapp logins` shows
"<host>/<owner> (user ...; for <owner>'s apps)"; `logout
<host>/<Owner>` (any case) forgets it. Keys are lowercase; git's header
is scoped to `https://<host>/<Owner>/` as the URL spells the owner
(`git config --get-urlmatch` gives it for `/Owner/app`, not for
`/owner/app`, `/Ownerx/app` or other owners). The image is pulled with
the owner's token (`<registry>/<owner>/<name>`), or else the host's;
re-installing pub-test with the host's token pulls it again (same
digest), with no docker login left.
7. `coreapp remove` in the app's folder (or `coreapps remove <name>` on the
Core) removes it like any other.
Without a public repository, the fetch can be tested on a local bare
repository (`git config uploadpack.allowFilter true`) by loading
`core/coreapps` as a module and replacing `REPO_URL`, `normalize_url`,
`resolve` and `GIT_ENV["GIT_ALLOW_PROTOCOL"]` for `file://` (only in the
test).
## Publishing (coreapp publish)
With a throwaway registry on the workstation
(`docker run -d --rm --name coreapp-test-registry -p 127.0.0.1:5000:5000 registry:2`;
`docker stop coreapp-test-registry` afterwards removes it) and an app in a git
repository with an `https://` origin:
1. With `image = "localhost/coreapp/..."`: refused, suggesting an image
from the remote (`https://host/Owner/Repo.git` gives
`host/owner/repo`).
2. With `image = "localhost:5000/test/<name>"` and an uncommitted change:
refused.
3. Committed: builds, pushes, prints the digest, tags the commit
`v<version>` (annotated) and prints the push commands. The registry
lists the tag (`curl -s http://127.0.0.1:5000/v2/test/<name>/tags/list`);
the image has the `org.opencontainers.image.*` labels (version,
revision, title, source).
4. Again: "already published", nothing pushed.
5. A new commit without raising `version`: "The tag v<version> already
exists on another commit".
6. Raise `version`, commit, publish: the new tag is pushed alongside.
7. Registry stopped: "Couldn't check ..." with the error, exit 1.
Against a real Gitea (needs the user's account): `docker login <gitea-host>`
with a token that has `write:package`, `image = "<gitea-host>/<owner>/<repo>"`,
`coreapp publish`: the package shows under the owner's Packages, linked to
the repository. A private owner's packages need a login to pull.
The workflow (`.gitea/workflows/publish.yml`), on a repository with an
Actions runner that can use Docker and the secrets `REGISTRY_USER` and
`REGISTRY_TOKEN`: pushing tag `v<version>` publishes `image:version`; a tag
that doesn't match `version`, a `localhost/` image, or a version already
published fails the job with a message.