Files
connector-macos/smoketest/scenarios/30-core-local.sh
T
davidandClaude Opus 5.5 08e6b2ee4f Set up a Mac for a Federated Core, like CoreDesktop's configure
A macOS counterpart of CoreDesktop's configure, with the same drop-in
items in configure.d/:

- core: Mail, Calendar and Contacts through a configuration profile,
  Superpanel as an app, Nextcloud files through the Nextcloud app, and
  Element; with test-and-fix, password change and removal
- tailscale: join the Core's network through headscale
- backup: restic to Nextcloud through rclone, run by launchd through an
  app that can be given Full Disk Access
- storage: SMB shares mounted the way Finder does, again at login and
  on network changes
- agents, claude, opencode, hermes, sandbox: install the agents and run
  them in Anthropic's sandbox runtime (Seatbelt on macOS)
- ai-servers: LLM servers on this Mac or the network, for the agents

Apps and tools macOS lacks are offered for download, checked against
their makers' Team IDs and notarization, or published SHA-256 sums.
Everything runs on macOS' bash 3.2 with only built-in tools.

smoketest/ runs scenarios in fresh macOS VMs with Tart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:34:42 -07:00

67 lines
3.4 KiB
Bash

# shellcheck shell=bash
DESCRIPTION="The Core item's local parts: the profile, Superpanel's app, Element's and Nextcloud's config"
TIER=quick
source "$CONNECTOR/configure.d/10-core.sh"
superpanel_opens() {
open -g -W "$SUPERPANEL_APP"
}
scenario() {
local dir file uuid icon
CORE_DOMAIN=smoke.invalid CORE_EMAIL=jo@smoke.invalid CORE_NAME='Jo "Q" & <Co>'
core_names
PASSWORD='p&ss<w>"rd '\''x' APP_PASSWORD=abc123XYZ
step "Mail settings for a domain without autoconfig"
mail_settings
check_eq "falls back to the usual IMAP server" "mail.smoke.invalid 993 SSL" "$IMAP_HOST $IMAP_PORT $IMAP_SOCKET"
check_eq "...and SMTP" "mail.smoke.invalid 587 STARTTLS" "$SMTP_HOST $SMTP_PORT $SMTP_SOCKET"
step "The profile"
dir="$(mktemp -d)"
file="$dir/$PROFILE_NAME.mobileconfig"
uuid="$(uuidgen)"
check "write_profile, and plutil -lint takes it" write_profile "$file" "mail calendar contacts" "$uuid"
check_eq "the mail password survives escaping" "$PASSWORD" \
"$(plutil -extract PayloadContent.0.IncomingPassword raw -o - "$file")"
check_eq "the name survives escaping" "$CORE_NAME" \
"$(plutil -extract PayloadContent.0.EmailAccountName raw -o - "$file")"
check_eq "CalDAV payload" com.apple.caldav.account "$(plutil -extract PayloadContent.1.PayloadType raw -o - "$file")"
check_eq "CardDAV payload" com.apple.carddav.account "$(plutil -extract PayloadContent.2.PayloadType raw -o - "$file")"
check_eq "payload UUIDs stay the same" "$(stable_uuid "$PROFILE_ID.mail")" \
"$(plutil -extract PayloadContent.0.PayloadUUID raw -o - "$file")"
check "profiles show -output stdout-xml gives a property list" bash -c \
"source '$CONNECTOR/configure.d/lib/profile.sh'; profiles_xml | plutil -lint -s -"
check_not "profile_installed is false for a profile that isn't" profile_installed "$PROFILE_ID"
check "open hands the profile to System Settings" open -g "$file"
skip "Installing it needs a click in System Settings: check that by hand (see README)"
rm -rf "$dir"
step "Superpanel's app"
SUPERPANEL="https://example.com"
SUPERPANEL_APP="$HOME/Applications/Superpanel (smoke).app"
check "setup_superpanel" setup_superpanel
check "its signature checks out" codesign --verify --deep --strict "$SUPERPANEL_APP"
check "it opens" superpanel_opens
icon="$TMPDIR/icon.png"
check "an icon converts to .icns" bash -c "sips -s format png -z 512 512 \
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns \
--out '$icon' && sips -s format icns '$icon' --out '$SUPERPANEL_APP/Contents/Resources/applet.icns'"
check "re-signed after the icon changes" codesign --force --sign - "$SUPERPANEL_APP"
check "...and still checks out" codesign --verify --deep --strict "$SUPERPANEL_APP"
check "...and opens" superpanel_opens
step "Element and Nextcloud"
MATRIX="https://matrix.smoke.invalid"
check "setup_element writes Element's config" setup_element
check_eq "...pointing at the Core" matrix.smoke.invalid \
"$(json_get 'd.default_server_config["m.homeserver"].server_name' < "$ELEMENT_CONFIG")"
mkdir -p "$(dirname "$NEXTCLOUD_CFG")"
printf '[Accounts]\n0\\url=https://nextcloud.smoke.invalid\n' > "$NEXTCLOUD_CFG"
check "files_done finds the account in nextcloud.cfg" files_done
printf '[Accounts]\n0\\url=https://nextcloud.smoke.invalid.evil\n' > "$NEXTCLOUD_CFG"
check_not "...and not another server's" files_done
}