The Vikunja rehearsal's agent could only test sign-in against a stand-in Authelia. coreapp signin follows the app's sign-in through the Core's real Authelia as a test person (coreapp.test, made by coreapps test-account with a new random password each run, kept nowhere), prints each step with Authelia's errors, and says whether it got back to the app signed in. --code covers apps that start sign-in in the browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 KiB
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
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
- If the system was last upgraded more than a day ago,
bash install.shsays so and runsupdatefirst (pacman's lists would otherwise name versions the mirrors have deleted: 404s). Underupdateitself (COREDESKTOP_ALLOW_PACMAN=1) it doesn't. bash install.sh. It should:- install whichever of
libvirt qemu-base virt-install dnsmasq edk2-ovmf dmidecodeare missing - enable and start
libvirtd.service - add you to the
libvirtgroup - define the
defaultnetwork 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
- install whichever of
- Log out and back in, then check:
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 - Run
bash install.shagain. It must succeed, print "already enabled" and change nothing. - Error paths:
- With CoreDesktop missing:
HOME=$(mktemp -d) bash install.shshould say it needs CoreDesktop and exit 1.
- With CoreDesktop missing:
update.sh
bash update.shwith everything already installed: no package installs, no prompts apart from sudo, exits 0.- Stop the network (
virsh -c qemu:///system net-destroy default) and runbash update.sh: it should start the network again.
Through CoreDesktop's sibling command
Once the repo is in git:
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:
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.shagain: no changes, and no ufw rules added twice. (This also checks that thegreppatterns match how ufw writes its rules; if one doesn't,updateasks 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):
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
sysctlerror is expected inside a container). -
Moving from the old network (192.168.123.0/24): with a VM running,
bash update.shredefinescoreappbut doesn't restart it, and says how. With no VM running, it restarts it:net-dumpxml coreappshows10.123.0.1and thedhcp-host=52:54:00:c0:4e:10,...option, andsudo iptables -S | grep -c 192.168.123prints 0. -
The reservation works:
virsh -c qemu:///system net-dhcp-leases coreapplistscoreserverat10.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
- Put Federated's dashboard key in
~/.config/coreapp-dev/authorized_keys. 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 printsIP: 10.123.0.10within about two minutes.coreapp-vm list:coreserveris running at 10.123.0.10.coreapp-vm sshlogs in (after cloud-init, a minute later). Inside the VM:cat /root/.ssh/authorized_keyshas both keysdf -h /federatedshows about 50 GB (the disk is 60 GB;/stays 10 GB)ping -c3 1.1.1.1andgetent hosts federated.computer(internet and DNS)systemctl is-enabled systemd-resolvedsaysmasked
coreapp-vm ssh hostnameprintscoreserver;coreapp-vm ip nopesays there's no such VM.coreapp-vm createagain refuses with "already exists".- To see the screen:
virt-viewer -c qemu:///system coreserver. - Once the Core is installed:
virsh -c qemu:///system reboot coreserver. Within a few minutes all its containers are up again, includingpdns(dig +short A <domain> @10.123.0.10answers). coreapp-vm stop, thencoreapp-vm start.coreapp-vm delete: asks for the name; anything else keeps the VM. With the name, the VM and/var/lib/libvirt/images/coreserver.qcow2are gone, the image in~/.local/share/coreapp-dev/images/stays.
Uninstall
On a machine you can rebuild (it removes the network every VM uses):
bash uninstall.shwith a VM on thecoreappnetwork, answering no: it stops, and nothing is removed.- Again, answering yes: the VMs and their disks are gone,
virsh -c qemu:///system net-list --allhas nocoreapp,/etc/libvirt/hooks/network.d/coreapp-devis gone,sudo iptables -S | grep -c coreapp-devprints 0,grep -c virbr-coreapp /etc/ufw/user.rulesprints 0 (virbr0's rules stay), andcoreapp-vmisn't onPATH. - Answering no to the data questions keeps
~/.local/share/coreapp-devand~/.config/coreapp-dev. bash install.shputs everything back.
The skill
- After
bash update.sh,~/.claude/skills/coreappis a link toskills/coreappin the clone; running it again changes nothing. With a real folder already at that path, it says so and leaves it. uninstall.shremoves the link (only if it points at askills/coreapp).- 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.tomland a Dockerfile, move state to/data, useAPP_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 = 0image = "coreapp/x"(no registry, which would mean Docker Hub)title = "A $(reboot)", adescriptionwith"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.
cd $(mktemp -d) && coreapp new hello:./hellohascoreapp.toml,Dockerfile,.dockerignore,icon.png,www/,README.mdand.gitea/workflows/publish.yml, and nothing else, with no placeholder left (grep -r '{{[A-Z]' helloprints nothing; the workflow's${{ ... }}are Gitea's).coreapp new helloagain refuses; so doescoreapp new x-.cd hello && coreapp deploy: updates/opt/coreappson the Core, builds, copies the image, printsInstalling hello at 192.168.5.x(the first free address there) andInstalled: https://hello.<domain>/. On the Core,/federated/services/hello/hasservice,docker-compose.yml.in,env.in,install,uninstall,icon.png,coreapp.tomland.coreapp(needs=);/federated/apps/hello/.envis root's, mode 600, withIMAGE_VERSIONequal toversionand a randomAPP_SECRET. Superpanel's catalog (/federated/apps/superpanel/data/catalog.json) listshello.coreapp check:OK: HTTP 200, valid certificate.(the first certificate can take a minute).- Change
www/index.html,coreapp deploy: "Updating hello to 0.1.0", the container is recreated, the page shows the change,.envis unchanged.coreapp deployagain: "The Core already has this image.", and the container is the same (docker inspect -f '{{.Created}}');coreapp deploy --recreate: a new container, same data. - Raise
versionto 0.2.0,coreapp deploy: "Updated"; the container runs:0.2.0;docker image ls localhost/coreapp/helloon the Core lists only 0.2.0. coreapp status(address and port),coreapp logs,coreapp shell(exit withexit),coreapp shell 'id; echo $APP_URL'(prints both, no terminal needed, also when piped),coreapp list(all apps installed by coreapps).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 listshello.- Refused, with nothing changed on the Core:
name = "nextcloud"(one of Federated's apps) orname = "mail"image = "localhost/coreapp/nope"with no such image on the Core (changeimage, and skip coreapp's build by runningcoreapp-vm ssh /opt/coreapps/coreapps install <dir>on a copy)- with the app installed with
needs = ["postgres"], deploying withneeds = []("drops needs postgres")
/datais writable by the app: with an image that runs asnobody(the--postgres/--ssoexamples),coreapp shellthentouch /data/xworks; on the Core,/federated/apps/<name>/databelongs to uid 65534.- A failed update rolls back. Note
md5sumof the app's.env,docker-compose.yml,serviceand.coreappon the Core. Raiseversion, setport = 9999(nothing answers there) and add"postgres"toneeds, 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 fromdocker image ls, andcoreapp_helloisn't in PostgreSQL. With the sameversion(andport = 9999): "Rolled back hello (its settings and /data as before the update). It's the same image tag as before". Data: an app withneeds = ["postgres"](then again with["mysql"]), a table with a row "before" and/data/filewith "before". Start a failing update; once/federated/apps/.coreapps-rollback-<name>-*/hasdb.dump(db.sql) anddata, 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. - Superpanel: after deploy,
/federated/apps/superpanel/data/applist.json(the dashboard) andcatalog.jsonhave the app;servicehasURL="https://hello.$DOMAIN/"and applist the sameurl. Changetitle, raiseversion, deploy: both files have the new title. Aftercoreapp remove, neither has it. An app installed from a repository with nodocshasDOCS=<the repository>inserviceand applist. - Icons:
python3 core/coreapps manifest .printsicon=andicon_note=: noicon.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-PNGicon.png: "Note: icon.png isn't a PNG, so the Core shows the default icon instead." once, and the Core'sservices/<name>/icon.pngis the default.coreapp publish(in a git repository,imagenot localhost/) refuses a non-PNG icon, and one in.gitignore("isn't in the repository"), before it looks at the registry. - 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
coreapp new --postgres guest-book: hasapp.py, nowww/;coreapp.tomlhasneeds = ["postgres"]andhealth = "/health"; the README has a Database section.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 -llistscoreapp_guest_book, owned bycoreapp_guest_book;.envhasDB_*.- Change
app.py,coreapp deploy: the change shows, the count continues. 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).coreapp remove: thecoreapp_guest_bookdatabase 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
coreapp new --sso sso-demo: hasapp.pyandoidc.py, nowww/;needs = ["sso"]; the README has a Sign-in section.coreapp deploy,coreapp check. On the Core,idproviders.ymlhas one### coreapp-sso-demo beginblock; Authelia is healthy;docker exec authelia authelia validate-configis OK; no*.bakis left;/federated/apps/sso-demo/docker-compose.ymlmapsauthelia.<domain>to traefik's address (extra_hosts).https://sso-demo.<domain>/loginredirects tohttps://authelia.<domain>/api/oidc/authorization?...client_id=coreapp-sso-demo...code_challenge_method=S256.- 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. - 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. - Redeploy: still one client block, and Authelia isn't restarted
(
docker inspect -f '{{.State.StartedAt}}' autheliaunchanged).coreapp remove: no block and no copy, and running/federated/bin/reconcile-authelia-ssodoesn't bring it back; Authelia healthy, other clients (Nextcloud) still work. Deploy again: one block. [sso]:coreapps manifestprintssso_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.- Add
[sso] token_auth = "client_secret_post"to an installed app and deploy: its block saysclient_secret_postand Authelia restarted and is healthy; remove it, deploy:client_secret_basicagain.callback = "/auth/openid/core",pkce = false: the block has that redirect URI,require_pkce: falseand nopkce_challenge_method; Authelia's authorize URL with thatredirect_urigoes to its login page, with/auth/callbackto aninvalid_requesterror. The copy (.<name>.oidc-client.yml) matches. - Stock Vikunja (
vikunja/vikunja:2.8.0with a busybox entrypoint,[sso] callback = "/auth/openid/core",pkce = false):/api/v1/infolists the "Federated Core" provider; a browser sign-in with a Core account works.coreapp signin --codegives a code for/auth/openid/core;POST /api/v1/auth/openid/core/callbackwith it andredirect_urlreturns a token, and/api/v1/userwith it iscoreapp.test@<domain>. 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 hasuid=coreapp.test,ou=people(inetOrgPerson, descriptioncoreapps: test account for coreapp signin); a second run sets a new password and reuses it.--cookies jar /login, thencurl -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 loginand in an app without "sso": refused.--code: the callback URL,code,state,code_verifier(PKCE apps only), exit 0.lib/signin.py --codewith a callback the client doesn't have: Authelia'sinvalid_requestand 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 signinmakes it again.coreapps test-accountwith less than 16 characters on stdin: refused.
With mysql
needs = ["postgres", "mysql"]: refused ("postgres or mysql, not both");coreapp new --postgres --mysql xtoo.coreapp new --mysql my-test:needs = ["mysql"], deploy..envhasDB_HOST=pdnsmysql.<domain>,DB_PORT=3306,DB_NAMEandDB_USERcoreapp_my_test, a randomDB_PASSWORD;servicehasDEPENDS="pdnsmysql".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 databaseslists only its own;@@character_set_databaseisutf8mb4;powerdnsis denied (1044); a wrong password is denied (1045).- The install log (
/federated/logs/coreapps/my-test-install.log) has root's password only on Federated'sMYSQL_ROOTPASSWORD=lines. coreapp remove: nocoreapp%user or database left in MariaDB.
With email
coreapp new --email mail-test:needs = ["email"], deploy. On the Core,.envhasSMTP_HOST=mail.<domain>,SMTP_PORT=587,SMTP_SECURITY=starttls,SMTP_USER=coreapp-mail-test, a randomSMTP_PASSWORD,SMTP_FROM=mail-test@<domain>;servicehasDEPENDS="mail"; LDAP hasuid=coreapp-mail-test,ou=people,<base>withobjectClassaccount, simpleSecurityObject, PostfixBookMailAccount (no person),mailEnabled: FALSE,description: coreapps: mail-test, and a{SSHA}password.- From a container on the
corenetwork with the app's.env(docker run --rm --network core --env-file /federated/apps/mail-test/.env ...), Python'ssmtplib: STARTTLS with certificate checking, login,MAIL FROMSMTP_FROMandRCPT TO postmaster@<domain>both 250 (thenRSET; nothing sent). A wrong password: 535. - Authelia's
/api/firstfactorascoreapp-mail-testwith its real password: 401.occ user:listin Nextcloud and Superpanel'suser_store(aftersuperpanel-sync-users) don't have it. coreapp remove: the LDAP entry is gone.- An LDAP entry
uid=coreapp-mail-testthat isn't the app's (anotherdescription): deploy prints "Warning: mail-test can't send mail", the entry is unchanged (its password too), and remove leaves it. - Adding
"email"to an installed app'sneedsand deploying makes the account and adds theSMTP_*settings.
With both
coreapp new --postgres --sso team-visits:needs = ["postgres", "sso"];app.pyimportsoidcandpsycopg.coreapp deploy,coreapp check. On the Core,servicehasDEPENDS="postgresql authelia",.envhasDB_*andOIDC_*. 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.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).
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: "