Set up Pop!_OS for a Federated Core, like CoreDesktop's configure

A port of CoreDesktop's configure to Pop!_OS 24.04 with COSMIC, in the shape
of connector-macos: its own install.sh, update and configure, installed in
~/.local/share/federated-connector/connector.

Every configure item is ported: the Core (email, calendars and contacts
through GNOME Online Accounts and Evolution, as COSMIC has no accounts of its
own; Superpanel; files over davfs2; Element; Tally; the email watcher),
Tailscale, backups, AI agents in the sandbox and their sign-ins, languages
with mise, AI servers, printers, network storage and the agent sandbox.
Folders go in the COSMIC Files sidebar. Each item installs what it needs
from apt, Flathub or the tool's own apt repository when you set it up.

smoketest/run checks it in Ubuntu 24.04 containers with Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 14:20:47 -07:00
co-authored by Claude Opus 5.5
commit bc07e1d3e3
60 changed files with 5626 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
# Ubuntu 24.04, which Pop!_OS 24.04 is built on: the same apt packages,
# except COSMIC's own. A user "pop" with passwordless sudo, as configure
# expects an administrator. configure's own packages (install.sh's PACKAGES)
# are already in, to keep each scenario quick; 05-install takes one out.
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends sudo ca-certificates curl dbus-x11 gnome-keyring \
xz-utils procps iproute2 \
jq libsecret-tools python3-gi gir1.2-secret-1 libnotify-bin avahi-utils \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -s /bin/bash pop && echo 'pop ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/pop \
&& printf 'ID=pop\nNAME="Pop!_OS"\nPRETTY_NAME="Pop!_OS 24.04 LTS (smoketest)"\nVERSION_ID="24.04"\nID_LIKE="ubuntu debian"\nUBUNTU_CODENAME=noble\nVERSION_CODENAME=noble\n' > /etc/os-release
USER pop
WORKDIR /home/pop
+61
View File
@@ -0,0 +1,61 @@
# Smoketest
These tests run `configure`'s pieces on Ubuntu 24.04, which Pop!_OS 24.04 is built on, in throwaway Docker containers. A container has the same apt packages as Pop!_OS, except COSMIC's own, and `/etc/os-release` says Pop!_OS. Each scenario starts a session D-Bus and an unlocked gnome-keyring, as COSMIC does at login.
They check what lint can't:
- GNOME Online Accounts 3.50 without GNOME
- Ubuntu's restic, rclone, davfs2 and sshfs
- mise's apt repository
- the sandbox, with real downloads
## Running it
```
smoketest/run --list # scenarios and their tier
smoketest/run # the quick scenarios
smoketest/run --tier all # everything, including the downloads
smoketest/run 40-backup # one scenario (or: smoketest/run 40)
smoketest/run --keep 20 # keep the container afterwards, to look around
```
It tests the working copy as it is, including uncommitted changes. The first run builds the image. Each scenario takes a few seconds plus its own apt installs; `50-sandbox` downloads Node.js and srt, and runs with `--privileged` so bubblewrap can make user namespaces.
Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and prints which scenarios passed.
## Scenarios
| Scenario | Checks |
|----------|--------|
| `05-install` | `install.sh` piped into bash, as `curl \| bash` runs it, with the working copy. It installs a missing package again, links the commands, puts `~/.local/bin` on PATH for a new bash, and doesn't ask to run `configure` without a terminal. `update` swaps in a fresh copy without leaving staging folders behind. |
| `10-configure` | `--help`, `--list` (nothing on stderr; agent sign-ins and the sandbox item hidden until they apply), the menu, an unknown item, the Core item's first question, and refusing to run as root |
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
## What still needs Pop!_OS
A container has no COSMIC session, systemd user manager, FUSE mounts or AppArmor, so check these by hand on Pop!_OS 24.04:
- **COSMIC Files** shows a folder added to its sidebar, with its name.
- **Evolution** shows the email, calendars and contacts that `configure core` adds, against a real Core.
- **Mounting your files** with davfs2 after `configure core`, and again after logging out and in.
- **The services**: the backup timer, the email watcher's notification, and that clicking it opens `configure core` in COSMIC Terminal.
- **The AppArmor profile** for bubblewrap, if Pop!_OS restricts user namespaces.
- **Tailscale** joining a Core's headscale, and **SMB and SFTP mounts** of real servers.
## Writing a scenario
A scenario is a bash file in `scenarios/` that sets `DESCRIPTION` and `TIER`, either `quick` or `all`, and defines `scenario`. `PRIVILEGED=1` runs its container with `--privileged`. It runs with what `configure` gives items: `CONNECTOR`, `CONF_DIR`, and `confirm` and `confirm_yes`, which always answer yes. So it can source an item and call its functions. The user `pop` has passwordless sudo. Checks, from `lib/runner.sh`:
| Check | |
|-------|---|
| `check "what" cmd...` | ok if the command succeeds; otherwise FAIL, with its output |
| `check_not "what" cmd...` | ok if the command fails |
| `check_eq "what" expected actual` | ok if they're the same |
| `skip "why"` | Note something not checked |
| `step "what"` | A heading |
`check` runs its command in a subshell, so variables it sets don't last. Set those before the check.
+91
View File
@@ -0,0 +1,91 @@
#!/bin/bash
#
# Purpose : Run one smoketest scenario inside the container (smoketest/run
# starts this). Prints ok, FAIL or skip for each check, and exits 1
# if any failed.
#
# Usage: runner.sh <scenario file>
#
# A scenario sets DESCRIPTION and TIER and defines `scenario`, which calls the
# checks below. It runs with what configure gives items (CONNECTOR, CONF_DIR,
# confirm...), answering yes to every question, so it can source items and
# call their functions. A desktop session's D-Bus and an unlocked keyring are
# started first, as COSMIC starts them at login.
CONNECTOR="$HOME/connector"
CONF_DIR="$HOME/.config/federated-connector"
export CONNECTOR CONF_DIR
RED=$'\033[31m' GREEN=$'\033[32m' YELLOW=$'\033[33m' RESET=$'\033[0m'
FAILURES=0
# configure's questions, answered yes
confirm() { echo "$1 [y/N] y"; return 0; }
confirm_yes() { echo "$1 [Y/n] y"; return 0; }
# check <description> <command...>: ok if the command succeeds
check() {
local description="$1" output
shift
if output="$("$@" 2>&1)"; then
echo "${GREEN}ok$RESET $description"
else
echo "${RED}FAIL$RESET $description"
[ -n "$output" ] && printf '%s\n' "$output" | tail -n 15 | sed 's/^/ /'
FAILURES=$((FAILURES + 1))
fi
}
# check_not <description> <command...>: ok if the command fails
check_not() {
local description="$1"
shift
if "$@" > /dev/null 2>&1; then
echo "${RED}FAIL$RESET $description (it succeeded)"
FAILURES=$((FAILURES + 1))
else
echo "${GREEN}ok$RESET $description"
fi
}
# check_eq <description> <expected> <actual>
check_eq() {
if [ "$2" = "$3" ]; then
echo "${GREEN}ok$RESET $1"
else
echo "${RED}FAIL$RESET $1"
echo " expected: $2"
echo " got: $3"
FAILURES=$((FAILURES + 1))
fi
}
skip() {
echo "${YELLOW}skip$RESET $1"
}
step() {
echo "-- $*"
}
# The session D-Bus and keyring
export XDG_RUNTIME_DIR="/tmp/runtime-$UID"
mkdir -p -m 700 "$XDG_RUNTIME_DIR"
eval "$(dbus-launch --sh-syntax)"
echo -n smoketest | gnome-keyring-daemon --unlock --components=secrets > /dev/null
export PATH="$HOME/.local/bin:$PATH"
cd "$HOME" || exit 1
source "$CONNECTOR/configure.d/lib/packages.sh"
source "$CONNECTOR/configure.d/lib/agents.sh"
# shellcheck disable=SC1090
source "$1" || { echo "Couldn't read $1"; exit 1; }
echo "$DESCRIPTION"
echo "($(. /etc/os-release && echo "$PRETTY_NAME"), $(uname -m))"
scenario
echo
if [ $FAILURES -eq 0 ]; then
echo "${GREEN}All checks passed.$RESET"
else
echo "${RED}$FAILURES check(s) failed.$RESET"
exit 1
fi
Executable
+111
View File
@@ -0,0 +1,111 @@
#!/bin/bash
#
# Purpose : Run the smoketest scenarios, each in a fresh Ubuntu 24.04
# container (Pop!_OS 24.04's base) with Docker. See README.md.
#
# Usage: smoketest/run [--tier quick|all] [--keep] [scenario...]
# smoketest/run --list
# Wrapped in { ...; exit; } so bash reads the whole script up front
{
SMOKETEST="$(cd "$(dirname "$0")" && pwd)"
REPO="$(dirname "$SMOKETEST")"
IMAGE="federated-connector-popos-smoketest"
TIER=quick
KEEP=0
SCENARIOS=()
usage() {
cat << EOF
Usage: smoketest/run [options] [scenario...]
--tier quick|all quick leaves out the slow scenarios (default: quick)
--keep Leave each container afterwards, to look around in it
--list List the scenarios and their tier
Scenarios are named by file name or number, e.g. 40-backup or 40.
EOF
}
scenario_var() {
sed -nE "s/^$2=\"?([^\"]*)\"?.*/\\1/p" "$1" | head -n 1
}
list() {
local file
for file in "$SMOKETEST"/scenarios/*.sh; do
printf '%-20s %-6s %s\n' "$(basename "$file" .sh)" "$(scenario_var "$file" TIER)" \
"$(scenario_var "$file" DESCRIPTION)"
done
}
while [ $# -gt 0 ]; do
case "$1" in
--tier) TIER="$2"; shift 2 ;;
--keep) KEEP=1; shift ;;
--list) list; exit 0 ;;
-h|--help) usage; exit 0 ;;
-*) usage; exit 2 ;;
*) SCENARIOS+=("$1"); shift ;;
esac
done
command -v docker > /dev/null || { echo "Docker isn't installed."; exit 1; }
# The scenario files to run
pick() {
local file name want
for file in "$SMOKETEST"/scenarios/*.sh; do
name="$(basename "$file" .sh)"
if [ ${#SCENARIOS[@]} -eq 0 ]; then
[ "$TIER" = all ] || [ "$(scenario_var "$file" TIER)" = quick ] || continue
echo "$file"
else
for want in "${SCENARIOS[@]}"; do
case "$name" in "$want"|"$want"-*) echo "$file" ;; esac
done
fi
done
}
mapfile -t FILES < <(pick)
if [ ${#FILES[@]} -eq 0 ]; then
echo "No scenarios to run. smoketest/run --list shows them."
exit 2
fi
echo "Building the image..."
docker build -q -t "$IMAGE" "$SMOKETEST" > /dev/null || exit 1
RESULTS="$SMOKETEST/results/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$RESULTS"
PASSED=() FAILED=()
for file in "${FILES[@]}"; do
scenario="$(basename "$file" .sh)"
log="$RESULTS/$scenario.log"
echo
echo "== $scenario: $(scenario_var "$file" DESCRIPTION)"
# The sandbox needs to make user namespaces, which Docker's defaults forbid
extra=()
[ "$(scenario_var "$file" PRIVILEGED)" = 1 ] && extra=(--privileged)
rm_flag=(--rm)
[ $KEEP -eq 1 ] && rm_flag=(--name "fc-smoke-$scenario-$$")
# The working copy, as it is now, read-only at /src and copied to ~/connector
docker run "${rm_flag[@]}" "${extra[@]}" -v "$REPO:/src:ro" "$IMAGE" bash -c '
mkdir ~/connector && tar -C /src --exclude ./.git --exclude .claude --exclude ./smoketest/results -cf - . \
| tar -xf - -C ~/connector && bash ~/connector/smoketest/lib/runner.sh ~/connector/smoketest/scenarios/'"$scenario"'.sh' \
2>&1 | tee "$log"
status=${PIPESTATUS[0]}
[ $KEEP -eq 1 ] && echo " Kept the container: docker start -ai fc-smoke-$scenario-$$ (docker rm it afterwards)"
if [ "$status" -eq 0 ]; then PASSED+=("$scenario"); else FAILED+=("$scenario"); fi
done
echo
echo "Passed: ${PASSED[*]:-none}"
echo "Failed: ${FAILED[*]:-none}"
echo "Logs: $RESULTS"
[ ${#FAILED[@]} -eq 0 ]
exit
}
+29
View File
@@ -0,0 +1,29 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="install.sh piped into bash, as curl | bash runs it, then update"
TIER=quick
scenario() {
step "Install the working copy, with jq missing"
sudo apt-get remove -y jq > /dev/null 2>&1
export FEDERATED_CONNECTOR_SOURCE="$CONNECTOR"
bash < "$CONNECTOR/install.sh" > "$HOME/install.log" 2>&1
check_eq "install.sh succeeds" 0 $?
check "it installed jq again" pkg_installed jq
check "configure is linked in ~/.local/bin" test -L "$HOME/.local/bin/configure"
check "update is linked in ~/.local/bin" test -L "$HOME/.local/bin/update"
check "the install is in place" test -x "$HOME/.local/share/federated-connector/connector/configure"
check_eq "it records the version" local "$(cat "$HOME/.local/share/federated-connector/connector/.version")"
check "configure is on PATH in a new bash" bash -ic 'command -v configure' < /dev/null
check "it didn't ask to run configure without a terminal" grep -q "In a new terminal, run: configure" "$HOME/install.log"
check "it wrote a log" compgen -G "$HOME/.local/state/federated-connector/install-*.log"
step "update"
check "update --version" "$HOME/.local/bin/update" --version
"$HOME/.local/bin/update" > "$HOME/update.log" 2>&1
check_eq "update succeeds" 0 $?
check "no staging folders are left" bash -c '! compgen -G "$HOME/.local/share/federated-connector/.connector-*"'
check_eq "the PATH block is in ~/.bashrc once" 1 "$(grep -c '>>> Federated Connector commands >>>' "$HOME/.bashrc")"
check "the installed configure runs" "$HOME/.local/bin/configure" --help
}
+24
View File
@@ -0,0 +1,24 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="configure --help, --list, the menu, and an item's first question"
TIER=quick
scenario() {
local out err
check "--help" "$CONNECTOR/configure" --help
out="$("$CONNECTOR/configure" --list 2> "$HOME/err")"
err="$(cat "$HOME/err")"
check_eq "--list writes nothing on stderr" "" "$err"
for item in core tailscale backup agents languages ai-servers printers storage; do
check "--list has $item" grep -qE "^(done|to do) +$item " <<< "$out"
done
check_not "--list leaves out sign-ins for agents that aren't installed" grep -qE ' (claude|opencode|hermes) ' <<< "$out"
check_not "--list leaves out the sandbox item without WinBoat" grep -q ' sandbox ' <<< "$out"
check "the menu quits on q" bash -c "echo q | '$CONNECTOR/configure' | grep -q 'Federated Core on this computer'"
check_not "it doesn't warn that this isn't Pop!_OS" bash -c "echo q | '$CONNECTOR/configure' | grep -q 'made for Pop'"
check_eq "an unknown item exits 2" 2 "$("$CONNECTOR/configure" nonsense > /dev/null; echo $?)"
check "configure core gives up on a Superpanel it can't reach" \
bash -c "printf 'https://superpanel.smoke.invalid\n' | '$CONNECTOR/configure' core | grep -q \"Couldn't reach https://superpanel.smoke.invalid\""
check_not "it doesn't run as root" sudo "$CONNECTOR/configure" --list
}
+54
View File
@@ -0,0 +1,54 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="Email, calendars and contacts in GNOME Online Accounts 3.50, without GNOME"
TIER=quick
scenario() {
local G="$CONNECTOR/configure.d/lib/goa-account" out
step "Installing GNOME Online Accounts and Evolution's data server"
# Evolution itself is large and only shows what's here; its data server is
# what reads Online Accounts
sudo apt-get update > /dev/null && sudo apt-get install -y gnome-online-accounts evolution-data-server > /dev/null 2>&1
check "gnome-online-accounts is installed" pkg_installed gnome-online-accounts
source "$CONNECTOR/configure.d/10-core.sh"
goa_ready() { return 0; }
CORE_DOMAIN=smoke.invalid CORE_EMAIL=jo@smoke.invalid CORE_NAME='Jo "Q" Tester'
core_names
PASSWORD='p\ss "word"' APP_PASSWORD=app-password-1
step "Adding the accounts"
check "setup_nextcloud" setup_nextcloud
check "setup_email, with the usual servers when the domain has no autoconfig" setup_email
check "nextcloud_done" nextcloud_done
check "email_done" email_done
check "adding again changes nothing" setup_email
check_eq "there's one email account" 1 "$(grep -c '^Provider=imap_smtp' "$HOME/.config/goa-1.0/accounts.conf")"
check "IMAP is mail.smoke.invalid over SSL" grep -qx 'ImapHost=mail.smoke.invalid' "$HOME/.config/goa-1.0/accounts.conf"
check "SMTP uses STARTTLS on 587" grep -qx 'SmtpUseTls=true' "$HOME/.config/goa-1.0/accounts.conf"
check "the name survives quoting" grep -qxF 'Name=Jo "Q" Tester' "$HOME/.config/goa-1.0/accounts.conf"
check_eq "nothing is turned off" "" "$("$G" disabled owncloud "$CORE_USER@nextcloud.$CORE_DOMAIN")"
step "Pausing email, as email-watch does"
check_not "not paused at first" "$G" paused imap_smtp "$CORE_EMAIL"
check "pause" "$G" pause imap_smtp "$CORE_EMAIL"
check "paused" "$G" paused imap_smtp "$CORE_EMAIL"
jq -n '{"imap-password": "new", "smtp-password": "new"}' | "$G" update imap_smtp "$CORE_EMAIL" 2> /dev/null
check_eq "update saves the password; the server can't be reached, so it exits 3" 3 $?
check_not "update ends the pause" "$G" paused imap_smtp "$CORE_EMAIL"
step "Test a Core's account checks"
"$CONNECTOR/system/email-watch" --check-password "$CORE_EMAIL"
check_eq "email-watch can't tell without Nextcloud (1)" 1 $?
FIXES=() FIX_TITLES=() PROBLEMS=0
out="$(test_account "Email" imap_smtp "$CORE_EMAIL" setup_email fix_email enable_email)"
check "an unreachable mail server is a sign-in failure, not a wrong password" grep -q "can't sign in" <<< "$out"
check_not "...and isn't taken as an old password" grep -q "old password" <<< "$out"
step "Removing"
check "remove owncloud" "$G" remove owncloud "$CORE_USER@nextcloud.$CORE_DOMAIN"
check "remove imap_smtp" "$G" remove imap_smtp "$CORE_EMAIL"
check_not "nothing left" email_done
check "no passwords left in the keyring" bash -c '! secret-tool search --all xdg:schema org.gnome.OnlineAccounts 2>&1 | grep -q goa-identity'
}
+81
View File
@@ -0,0 +1,81 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="The Core item's local parts: Superpanel, Element, the Files sidebar, davfs2's secret"
TIER=quick
scenario() {
local fav="$HOME/.config/cosmic/com.system76.CosmicFiles/v1/favorites" F="$CONNECTOR/configure.d/lib/cosmic-favorites"
source "$CONNECTOR/configure.d/10-core.sh"
CORE_DOMAIN=smoke.invalid CORE_EMAIL=jo@smoke.invalid CORE_NAME=Jo
core_names
step "Superpanel"
check "setup_superpanel without its icon" setup_superpanel
check "superpanel_done" superpanel_done
check "it opens Superpanel" grep -qx 'Exec=xdg-open https://superpanel.smoke.invalid' "$SUPERPANEL_DESKTOP"
check "it falls back to a theme icon" grep -qx 'Icon=applications-internet' "$SUPERPANEL_DESKTOP"
step "Element"
check_eq "without Flatpak, Element's config is in ~/.config" "$HOME/.config/Element/config.json" "$ELEMENT_CONFIG"
mkdir -p "$HOME/.config/Element" && echo '{"brand": "Element"}' > "$ELEMENT_CONFIG"
check "setup_element" setup_element
check_eq "it points at the Core's Matrix server" "https://matrix.smoke.invalid" \
"$(jq -r '.default_server_config["m.homeserver"].base_url' "$ELEMENT_CONFIG")"
check_eq "it keeps the rest" Element "$(jq -r .brand "$ELEMENT_CONFIG")"
flatpak_installed() { [ "$1" = im.riot.Riot ]; }
check_eq "with the Flatpak, it's in the app's folder" \
"$HOME/.var/app/im.riot.Riot/config/Element/config.json" "$(element_config)"
unset -f flatpak_installed
source "$CONNECTOR/configure.d/lib/packages.sh"
step "The COSMIC Files sidebar"
check_not "no favorites file yet" test -f "$fav"
check "sidebar_add" sidebar_add /mnt/smoke.invalid smoke.invalid
check "COSMIC Files' defaults are kept" grep -q '^ Home,$' "$fav"
check "it's added as Named" grep -qF 'Named(path: "/mnt/smoke.invalid", name: "smoke.invalid")' "$fav"
check "sidebar_has" sidebar_has /mnt/smoke.invalid
check "it's in GTK's bookmarks" grep -qx 'file:///mnt/smoke.invalid smoke.invalid' "$HOME/.config/gtk-3.0/bookmarks"
# As COSMIC Files writes it (ron's pretty printer), with a network place
# and a name that needs escaping
cat > "$fav" << 'RON'
[
Home,
Documents,
Network(
uri: "sftp://nas.local/",
name: "NAS, \"main\"",
path: "/run/user/1000/gvfs/sftp:host=nas.local",
),
Path("/mnt/a (b)"),
Named(
path: "/mnt/smoke.invalid",
name: "old name",
),
]
RON
check "adding again replaces the old entry" "$F" add /mnt/smoke.invalid 'smoke "q" \ x'
check_eq "...once" 1 "$(grep -c '/mnt/smoke.invalid' "$fav")"
check "a name with quotes and backslashes is escaped" grep -qF 'name: "smoke \"q\" \\ x")' "$fav"
check "the network place survives" grep -qF 'Network(' "$fav"
check "a Path(...) is found" "$F" has '/mnt/a (b)'
check "remove" "$F" remove '/mnt/a (b)'
check_not "it's gone" "$F" has '/mnt/a (b)'
check "sidebar_remove" sidebar_remove /mnt/smoke.invalid
check_not "removed from COSMIC Files" sidebar_has /mnt/smoke.invalid
check_not "removed from GTK's bookmarks" grep -q smoke.invalid "$HOME/.config/gtk-3.0/bookmarks"
check_eq "three places are left" 3 "$(python3 -c "
import importlib.machinery, importlib.util, sys
loader = importlib.machinery.SourceFileLoader('f', '$F')
m = importlib.util.module_from_spec(importlib.util.spec_from_loader('f', loader)); loader.exec_module(m)
print(len(m.load()))")"
echo 'not ron' > "$fav"
check_not "a file that isn't a RON list is left alone" "$F" add /mnt/x x
check_eq "...unchanged" "not ron" "$(cat "$fav")"
step "davfs2's secret"
APP_PASSWORD='a"b\c d'
check "save_files_secret" save_files_secret
check_eq "only you can read it" 600 "$(stat -c %a "$HOME/.davfs2/secrets")"
check_eq "the app password reads back" 'a"b\c d' "$(files_app_password)"
}
+45
View File
@@ -0,0 +1,45 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="A backup with Ubuntu's restic and rclone to a local WebDAV server standing in for Nextcloud"
TIER=quick
scenario() {
local served="$HOME/served" webdav="http://127.0.0.1:8080/remote.php/dav/files/jo"
step "Installing restic and rclone"
sudo apt-get update > /dev/null && sudo apt-get install -y restic rclone > /dev/null 2>&1
check "restic and rclone are installed" pkg_installed restic rclone
echo "restic $(restic version | cut -d' ' -f2), $(rclone version | head -n 1)"
# Nextcloud's WebDAV, and status.php, which the backup waits for
mkdir -p "$served/remote.php/dav/files/jo"
echo '{"installed":true,"maintenance":false}' > "$served/status.php"
rclone serve webdav "$served" --addr 127.0.0.1:8080 --user jo --pass app-password > "$HOME/serve.log" 2>&1 &
sleep 2
step "Setting up, as configure backup does"
mkdir -p "$CONF_DIR"
printf 'BACKUP_WEBDAV=%q\nBACKUP_USER=jo\nBACKUP_DIR=.backup-smoke\n' "$webdav" > "$CONF_DIR/backup.conf"
printf app-password | secret-tool store --label test federated-connector backup item nextcloud url "$webdav"
printf 'pass phrase' | secret-tool store --label test federated-connector backup item passphrase url "$webdav/.backup-smoke"
source "$CONNECTOR/system/backup-env.sh"
check_eq "restic uses rclone's WebDAV" "rclone::webdav:.backup-smoke" "$RESTIC_REPOSITORY"
check "the passphrase comes from the keyring" test -n "$RESTIC_PASSWORD_COMMAND"
check "rclone reaches the server with the app password" rclone lsf ":webdav:"
check "restic init" restic init
step "A backup"
mkdir -p "$HOME/Documents" "$HOME/.cache/big"
echo "keep me" > "$HOME/Documents/note.txt"
echo "leave me out" > "$HOME/.cache/big/file"
check "system/backup" "$CONNECTOR/system/backup"
check_eq "there's one snapshot" 1 "$(restic snapshots --json | jq length)"
check "a file restores from it" restic restore latest --target "$HOME/restored" --include "$HOME/Documents"
check_eq "...as it was" "keep me" "$(cat "$HOME/restored$HOME/Documents/note.txt")"
check_not "caches are left out" bash -c "restic ls latest | grep -q '/.cache/big'"
check_not "the install is left out" bash -c "restic ls latest | grep -q '/.local/share/federated-connector/'"
step "Without the passphrase in the keyring"
secret-tool clear federated-connector backup item passphrase url "$webdav/.backup-smoke"
check_not "system/backup fails" "$CONNECTOR/system/backup"
}
+48
View File
@@ -0,0 +1,48 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="Node.js and srt download; a stand-in agent in the sandbox"
TIER=all
PRIVILEGED=1
scenario() {
local project="$HOME/Projects/demo" out
source "$CONNECTOR/configure.d/30-agents.sh"
sudo apt-get update > /dev/null && sudo apt-get install -y "${SANDBOX_PACKAGES[@]}" > /dev/null 2>&1
check "bubblewrap works" bwrap_works
step "Node.js and srt"
check_not "Ubuntu's Node.js, if any, isn't new enough or isn't there" node_ok
check "install_srt" install_srt
check "Node.js is in ~/.local/share/federated-connector/node" test -x "$FC_TOOLS/node/bin/node"
check "srt is found" srt_path
step "A stand-in agent"
mkdir -p "$HOME/.local/bin" "$HOME/.ssh" "$project"
echo secret > "$HOME/.ssh/id_test"
cat > "$HOME/.local/bin/opencode" << 'AGENT'
#!/bin/bash
case "$1" in
read-ssh) cat ~/.ssh/id_test ;;
write-home) echo x > ~/outside ;;
write-here) echo x > ./inside ;;
fetch) curl -sf -o /dev/null --max-time 20 "$2" ;;
esac
AGENT
chmod +x "$HOME/.local/bin/opencode"
cd "$project" || return
check_not "it can't read ~/.ssh" "$SANDBOX_BIN/opencode" read-ssh
check_not "it can't write outside its project" "$SANDBOX_BIN/opencode" write-home
check "it can write in its project" "$SANDBOX_BIN/opencode" write-here
check "it reaches an allowed site" "$SANDBOX_BIN/opencode" fetch https://registry.npmjs.org/
check_not "it doesn't reach others" "$SANDBOX_BIN/opencode" fetch https://example.com/
check "unsandboxed runs it directly" "$SANDBOX_BIN/unsandboxed" opencode write-home
cd "$HOME" || return
out="$("$SANDBOX_BIN/opencode" write-here 2>&1)"
check "it won't start in your home folder" grep -q "Start opencode from a project directory" <<< "$out"
step "Typing its name runs it in the sandbox"
check "put_on_path" put_on_path
check "on_path" on_path
check_eq "a new bash finds the sandboxed one first" "$SANDBOX_BIN/opencode" "$(bash -ic 'command -v opencode' < /dev/null 2> /dev/null)"
}
+43
View File
@@ -0,0 +1,43 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="What configure expects of Ubuntu's packages: davfs2, sshfs, GTK's print backend, mise"
TIER=all
scenario() {
sudo apt-get update > /dev/null
step "davfs2, set up as configure core does"
echo "davfs2 davfs2/suid_file boolean true" | sudo debconf-set-selections
sudo apt-get install -y davfs2 > /dev/null 2>&1
check "mount.davfs is setuid, so you can mount without sudo" test -u /usr/sbin/mount.davfs
check "the davfs2 group exists" getent group davfs2
check "davfs2.conf names that group" grep -qE '^#?[[:space:]]*dav_group[[:space:]]+davfs2' /etc/davfs2/davfs2.conf
step "davfs2 installed first, without setuid"
sudo apt-get purge -y davfs2 > /dev/null 2>&1
echo "davfs2 davfs2/suid_file boolean false" | sudo debconf-set-selections
sudo apt-get install -y davfs2 > /dev/null 2>&1
check_not "not setuid" test -u /usr/sbin/mount.davfs
source "$CONNECTOR/configure.d/10-core.sh"
check "davfs2_ready makes it setuid" davfs2_ready
check "...it is" test -u /usr/sbin/mount.davfs
step "sshfs and SMB"
sudo apt-get install -y sshfs smbclient cifs-utils > /dev/null 2>&1
check "fusermount3 is where the SFTP unit expects it" test -x /usr/bin/fusermount3
check "smbclient lists shares with -g" bash -c "smbclient --help 2>&1 | grep -q -- '--grepable'"
step "Printing"
sudo apt-get install -y libgtk-3-0t64 > /dev/null 2>&1
check "GTK's CUPS backend is where setup-printers.sh looks" \
compgen -G '/usr/lib/*/gtk-3.0/*/printbackends/libprintbackend-cups.so'
check "libnss-mdns is a package" apt-cache show libnss-mdns
step "mise's apt repository"
source "$CONNECTOR/configure.d/40-languages.sh"
check "install_mise" install_mise
check "mise runs" mise --version
check "activate" activate
check "a new bash has mise" bash -ic 'command -v mise' < /dev/null
}