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>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="The scripts parse with macOS' bash 3.2, and the macOS tools they use are there"
|
||||
TIER=quick
|
||||
|
||||
# Patterns, expanded in CONNECTOR
|
||||
SCRIPTS=("configure" "configure.d/*.sh" "configure.d/lib/*.sh" "system/backup" "system/backup-env.sh"
|
||||
"system/storage-mount" "sandbox/agent" "smoketest/run" "smoketest/lib/runner.sh")
|
||||
|
||||
# Commands that macOS doesn't have, or that would start installing the
|
||||
# Command Line Tools if called (python3), outside comments
|
||||
uses_missing_tools() {
|
||||
(cd "$CONNECTOR" && grep -nE '(^|[^#[:alnum:]_-])(python3|jq|gsed|gawk|timeout|realpath|mapfile|readarray|declare -A)([^[:alnum:]_-]|$)' \
|
||||
configure configure.d/*.sh configure.d/lib/*.sh system/backup system/storage-mount sandbox/agent \
|
||||
| grep -vE ':[[:space:]]*#')
|
||||
}
|
||||
|
||||
scenario() {
|
||||
local pattern file tool
|
||||
check_eq "/bin/bash is 3.2" "3.2" "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}"
|
||||
for pattern in "${SCRIPTS[@]}"; do
|
||||
# shellcheck disable=SC2231
|
||||
for file in "$CONNECTOR"/$pattern; do
|
||||
check "parses: ${file#"$CONNECTOR"/}" /bin/bash -n "$file"
|
||||
done
|
||||
done
|
||||
check_not "no tools macOS doesn't have (python3, jq, timeout, mapfile...)" uses_missing_tools
|
||||
for tool in osascript plutil xmllint security profiles dns-sd sips osacompile codesign \
|
||||
pkgutil spctl hdiutil ditto installer launchctl shasum bunzip2 unzip nc md5 uuidgen \
|
||||
openssl scutil curl diskutil base64; do
|
||||
check "has $tool" command -v "$tool"
|
||||
done
|
||||
if command -v brew > /dev/null || [ -x /opt/homebrew/bin/brew ]; then
|
||||
skip "This image has Homebrew, so the download paths for tools Homebrew already has aren't tested"
|
||||
else
|
||||
check "no Homebrew, as on a new Mac" true
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="configure's menu, --list and an item run on bash 3.2 without errors"
|
||||
TIER=quick
|
||||
|
||||
list_quietly() {
|
||||
local out err
|
||||
err="$("$CONNECTOR/configure" --list 2>&1 > /dev/null < /dev/null)"
|
||||
[ -z "$err" ] || { echo "$err"; return 1; }
|
||||
}
|
||||
|
||||
lists() {
|
||||
"$CONNECTOR/configure" --list < /dev/null | grep -qE "^(to do|done) +$1 "
|
||||
}
|
||||
|
||||
scenario() {
|
||||
check "configure --help" "$CONNECTOR/configure" --help
|
||||
check "configure --list, nothing on stderr" list_quietly
|
||||
for item in core tailscale backup agents ai-servers storage; do
|
||||
check "--list has $item" lists "$item"
|
||||
done
|
||||
check_not "--list leaves out claude, opencode and hermes before they're installed" lists claude
|
||||
check_not "configure <unknown item> fails" "$CONNECTOR/configure" no-such-item
|
||||
check "the menu quits on q" bash -c "echo q | '$CONNECTOR/configure'"
|
||||
check "configure core asks for the Superpanel and rejects an empty one" \
|
||||
bash -c "printf '\n' | '$CONNECTOR/configure' core | grep -q \"That isn't a Superpanel address\""
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="JSON through JavaScript for Automation, and secrets in the login keychain"
|
||||
TIER=quick
|
||||
|
||||
source "$CONNECTOR/configure.d/lib/json.sh"
|
||||
source "$CONNECTOR/configure.d/lib/keychain.sh"
|
||||
|
||||
scenario() {
|
||||
local file="$TMPDIR/smoke.json" pass
|
||||
check_eq "json_get reads a value" abc123 \
|
||||
"$(echo '{"ocs":{"data":{"apppassword":"abc123"}}}' | json_get 'd.ocs.data.apppassword')"
|
||||
check_not "json_get fails on false" bash -c "source '$CONNECTOR/configure.d/lib/json.sh'; echo '{\"m\":false}' | json_get d.m"
|
||||
check_not "json_get fails on bad JSON" bash -c "source '$CONNECTOR/configure.d/lib/json.sh'; echo nope | json_get d.m"
|
||||
check_eq "json_get passes arguments as a[]" true \
|
||||
"$(echo '{"x":"a b"}' | json_get 'd.x === a[0]' 'a b')"
|
||||
rm -f "$file"
|
||||
check "json_edit makes a file" json_edit "$file" 'd.k = {"m.x": a[0]};' 'v"1'
|
||||
check_eq "json_edit wrote it" 'v"1' "$(json_get 'd.k["m.x"]' < "$file")"
|
||||
check "json_edit changes it" json_edit "$file" 'd.n = 2;'
|
||||
check_eq "json_edit kept what was there" 'v"1' "$(json_get 'd.k["m.x"]' < "$file")"
|
||||
echo 'not json' > "$file"
|
||||
check_not "json_edit leaves bad JSON alone" json_edit "$file" 'd.n = 3;'
|
||||
check_eq "...and doesn't change it" 'not json' "$(cat "$file")"
|
||||
|
||||
pass="$(openssl rand -base64 24)"
|
||||
check "keychain_save" keychain_save federated-smoke test "$pass"
|
||||
check_eq "keychain_load" "$pass" "$(keychain_load federated-smoke test)"
|
||||
check "keychain_save replaces" keychain_save federated-smoke test abc
|
||||
check_eq "keychain_load gets the new one" abc "$(keychain_load federated-smoke test)"
|
||||
check_not "keychain_save refuses a secret with spaces or quotes" keychain_save federated-smoke bad 'a b"c'
|
||||
check "keychain_delete" keychain_delete federated-smoke test
|
||||
check_eq "it's gone" "" "$(keychain_load federated-smoke test)"
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
# 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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="Finding things on the network with dns-sd (the VM announces its own ssh)"
|
||||
TIER=quick
|
||||
|
||||
source "$CONNECTOR/configure.d/lib/mdns.sh"
|
||||
|
||||
finds_type() {
|
||||
mdns_types | grep -qx '_ssh._tcp'
|
||||
}
|
||||
|
||||
finds_instance() {
|
||||
[ -n "$(mdns_instances _ssh._tcp)" ]
|
||||
}
|
||||
|
||||
resolves_own_host() {
|
||||
mdns_services _ssh._tcp | cut -d'|' -f3 | grep -qixF "$(mdns_own_host)"
|
||||
}
|
||||
|
||||
quick_enough() {
|
||||
local start=$SECONDS
|
||||
run_for 2 dns-sd -B _ssh._tcp local. > /dev/null
|
||||
[ $((SECONDS - start)) -le 4 ]
|
||||
}
|
||||
|
||||
scenario() {
|
||||
step "Remote Login is on in the VM, so it announces _ssh._tcp"
|
||||
check "run_for stops dns-sd on time" quick_enough
|
||||
check "mdns_types lists _ssh._tcp (dns-sd's output comes through a pipe)" finds_type
|
||||
check "mdns_instances lists the VM's ssh" finds_instance
|
||||
check "mdns_services resolves it to this Mac's .local name ($(mdns_own_host))" resolves_own_host
|
||||
check "mdns_hosts runs (and leaves this Mac out)" bash -c \
|
||||
"source '$CONNECTOR/configure.d/lib/mdns.sh'; ! mdns_hosts | grep -qixF \"\$(mdns_own_host)\""
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="Installs Node.js and srt, and the sandbox keeps a (fake) agent in: files, network, local servers"
|
||||
TIER=quick
|
||||
|
||||
source "$CONNECTOR/configure.d/30-agents.sh"
|
||||
source "$CONNECTOR/configure.d/50-ai-servers.sh"
|
||||
PROJECT="$HOME/proj"
|
||||
|
||||
# Run a command as the "opencode" agent, in the sandbox, from a project
|
||||
sandboxed() {
|
||||
(cd "$PROJECT" && "$CONNECTOR/sandbox/bin/opencode" "$@")
|
||||
}
|
||||
|
||||
fetch() {
|
||||
sandboxed /usr/bin/curl -fsS -o /dev/null --max-time 20 "$1"
|
||||
}
|
||||
|
||||
zsh_finds_sandboxed() {
|
||||
[ "$(zsh -ic 'command -v opencode' 2> /dev/null)" = "$CONNECTOR/sandbox/bin/opencode" ]
|
||||
}
|
||||
|
||||
scenario() {
|
||||
local node server
|
||||
step "Installing Node.js and srt"
|
||||
check "tool_ensure node srt" tool_ensure node srt
|
||||
check "Node.js is 22.12 or later" node_ok
|
||||
check "srt is found" srt_path
|
||||
|
||||
# The agent is a stand-in that runs what it's given, so commands can be
|
||||
# tried in its sandbox
|
||||
mkdir -p "$HOME/.local/bin" "$PROJECT" "$HOME/.ssh"
|
||||
printf '#!/bin/bash\nexec "$@"\n' > "$HOME/.local/bin/opencode"
|
||||
chmod +x "$HOME/.local/bin/opencode"
|
||||
echo secret > "$HOME/.ssh/smoke-secret"
|
||||
|
||||
step "Files"
|
||||
check "the agent runs in the sandbox" sandboxed /usr/bin/true
|
||||
check_not "it can't read ~/.ssh" sandboxed /bin/cat "$HOME/.ssh/smoke-secret"
|
||||
check_not "it can't read the keychains" sandboxed /bin/ls "$HOME/Library/Keychains"
|
||||
check "it can write in its project" sandboxed /usr/bin/touch "$PROJECT/written"
|
||||
check_not "it can't write elsewhere in your home folder" sandboxed /usr/bin/touch "$HOME/outside"
|
||||
check "it can write in /tmp" sandboxed /usr/bin/touch /tmp/smoke-written
|
||||
check "it can make temp files (mktemp)" sandboxed /usr/bin/mktemp
|
||||
check "it can open a pty (allowPty)" sandboxed /usr/bin/script -q /dev/null /usr/bin/true
|
||||
check_not "it won't start in your home folder" bash -c "cd ~ && '$CONNECTOR/sandbox/bin/opencode' /usr/bin/true"
|
||||
check "unsandboxed runs it outside" bash -c "cd '$PROJECT' && '$CONNECTOR/sandbox/bin/unsandboxed' opencode /bin/cat '$HOME/.ssh/smoke-secret'"
|
||||
|
||||
step "Network"
|
||||
check "it reaches an allowed site (registry.npmjs.org)" fetch https://registry.npmjs.org/
|
||||
check_not "it doesn't reach others (example.com)" fetch https://example.com/
|
||||
|
||||
step "An LLM server on this Mac"
|
||||
node="$(tool_path node)"
|
||||
"$node" -e 'require("http").createServer((q, s) => { s.setHeader("content-type", "application/json");
|
||||
s.end(JSON.stringify({data: [{id: "smoke-model"}]})); }).listen(11434, "127.0.0.1")' &
|
||||
server=$!
|
||||
sleep 2
|
||||
check_eq "server_models reads its models" smoke-model "$(server_models localhost:11434)"
|
||||
check_not "the agent can't reach it before it's allowed" fetch http://localhost:11434/v1/models
|
||||
check "sandbox_allow localhost:11434" sandbox_allow localhost:11434
|
||||
check "...then it can, through srt's proxy" fetch http://localhost:11434/v1/models
|
||||
check "sandbox_disallow" sandbox_disallow localhost:11434
|
||||
check_not "...then it can't again" fetch http://localhost:11434/v1/models
|
||||
kill "$server" 2> /dev/null
|
||||
|
||||
step "Shell and Claude Code"
|
||||
check "put_on_path" put_on_path
|
||||
check "a new zsh finds sandbox/bin's opencode first" zsh_finds_sandboxed
|
||||
check "turn_on_claude_sandbox" turn_on_claude_sandbox
|
||||
check "Claude Code's sandbox is on" claude_sandbox_on
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="Backup end to end: restic and rclone, the app, launchd, the keychain, a snapshot and a restore"
|
||||
TIER=quick
|
||||
|
||||
source "$CONNECTOR/configure.d/20-backup.sh"
|
||||
DAV="$HOME/davroot"
|
||||
SMOKE_FILE="$HOME/Documents/smoke-file.txt"
|
||||
|
||||
ran() {
|
||||
grep -qE 'Backup (finished|failed)' "$BACKUP_LOG" 2> /dev/null
|
||||
}
|
||||
|
||||
finished() {
|
||||
grep -q 'Backup finished' "$BACKUP_LOG" || { tail -n 30 "$BACKUP_LOG"; return 1; }
|
||||
}
|
||||
|
||||
has_snapshot() {
|
||||
[ "$(restic snapshots --host smoketest --json | json_get 'd.length')" -ge 1 ]
|
||||
}
|
||||
|
||||
restores() {
|
||||
local target="$TMPDIR/restored"
|
||||
rm -rf "$target"
|
||||
restic restore latest --host smoketest --target "$target" --include "$SMOKE_FILE" > /dev/null \
|
||||
&& cmp "$SMOKE_FILE" "$target$SMOKE_FILE"
|
||||
}
|
||||
|
||||
access_answer() {
|
||||
echo "?" > "$ACCESS_CHECK"
|
||||
open -g -W "$BACKUP_APP"
|
||||
cat "$ACCESS_CHECK"
|
||||
rm -f "$ACCESS_CHECK"
|
||||
}
|
||||
|
||||
scenario() {
|
||||
local pass answer lines DAV_SERVER
|
||||
step "Installing restic and rclone"
|
||||
check "tool_ensure restic rclone" tool_ensure restic rclone
|
||||
export PATH="$TOOLS_PATH:$PATH"
|
||||
|
||||
# A plain WebDAV server stands in for Nextcloud. Without a password, so the
|
||||
# backup's check that Nextcloud is up (status.php) answers.
|
||||
mkdir -p "$DAV" "$(dirname "$SMOKE_FILE")"
|
||||
echo ok > "$DAV/status.php"
|
||||
rclone serve webdav "$DAV" --addr 127.0.0.1:8081 > /dev/null 2>&1 &
|
||||
DAV_SERVER=$!
|
||||
sleep 3
|
||||
date > "$SMOKE_FILE"
|
||||
|
||||
WEBDAV=http://127.0.0.1:8081 BACKUP_DIR=.backup-smoketest
|
||||
mkdir -p "$CONF_DIR"
|
||||
{
|
||||
printf 'BACKUP_WEBDAV=%q\n' "$WEBDAV"
|
||||
printf 'BACKUP_USER=tester\nBACKUP_DIR=%q\nBACKUP_HOST=smoketest\nBACKUP_VENDOR=other\n' "$BACKUP_DIR"
|
||||
} > "$BACKUP_CONF"
|
||||
echo "$DAV" > "$CONF_DIR/backup-exclude"
|
||||
pass="$(openssl rand -base64 24)"
|
||||
check "the app password goes in the keychain" keychain_save "$BACKUP_KEYCHAIN" "nextcloud:$WEBDAV" smokepass
|
||||
check "the passphrase goes in the keychain" keychain_save "$BACKUP_KEYCHAIN" "passphrase:$WEBDAV/$BACKUP_DIR" "$pass"
|
||||
source "$CONNECTOR/system/backup-env.sh"
|
||||
check "backup-env.sh finds the passphrase" test -n "$RESTIC_PASSWORD_COMMAND"
|
||||
check "restic init, through rclone" restic init
|
||||
|
||||
step "The Federated Backup app and its launchd job"
|
||||
check "make_backup_app" make_backup_app
|
||||
check "the app knows which script it runs" backup_app_current
|
||||
check "its signature checks out" codesign --verify --deep --strict "$BACKUP_APP"
|
||||
answer="$(access_answer)"
|
||||
check "started as itself, it says whether it has Full Disk Access" test "$answer" = yes -o "$answer" = no
|
||||
[ "$answer" = no ] && skip "Full Disk Access needs a click in System Settings; this backup leaves protected folders out"
|
||||
touch "$CONF_DIR/backup-last"
|
||||
check "install_job" install_job
|
||||
check "launchd has the job" job_loaded
|
||||
|
||||
step "A backup, started the way configure does"
|
||||
touch "$NOW_REQUEST"
|
||||
launchctl kickstart "gui/$(id -u)/$LABEL"
|
||||
wait_until 900 ran > /dev/null
|
||||
check "it finished" finished
|
||||
check "restic has a snapshot from this Mac" has_snapshot
|
||||
check "a file comes back from it" restores
|
||||
lines="$(wc -l < "$BACKUP_LOG")"
|
||||
launchctl kickstart "gui/$(id -u)/$LABEL"
|
||||
sleep 15
|
||||
check_eq "started again within the day, it does nothing" "$lines" "$(wc -l < "$BACKUP_LOG")"
|
||||
|
||||
step "Turning backups off"
|
||||
stop_backups
|
||||
check_not "launchd no longer has the job" job_loaded
|
||||
check_not "the app is gone" test -e "$BACKUP_APP"
|
||||
kill "$DAV_SERVER" 2> /dev/null
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="Downloads Element, Nextcloud and Tailscale with Gatekeeper on: Team IDs, notarization, refusals"
|
||||
TIER=all
|
||||
|
||||
source "$CONNECTOR/configure.d/lib/json.sh"
|
||||
source "$CONNECTOR/configure.d/lib/apps.sh"
|
||||
|
||||
gatekeeper_on() {
|
||||
spctl --status | grep -q 'assessments enabled'
|
||||
}
|
||||
|
||||
# An app no one notarized: Gatekeeper should turn it down
|
||||
unnotarized_refused() {
|
||||
local app="$TMPDIR/Unnotarized.app"
|
||||
rm -rf "$app"
|
||||
osacompile -o "$app" -e 'return' && codesign --force --sign - "$app" > /dev/null 2>&1 || return 2
|
||||
! spctl --assess --type execute "$app" 2> /dev/null
|
||||
}
|
||||
|
||||
# Tailscale's package, offered as someone else's
|
||||
wrong_team_refused() {
|
||||
local pkg="$TMPDIR/tailscale.pkg"
|
||||
app_info tailscale
|
||||
curl -fsL --max-time 600 -o "$pkg" "$APP_URL" || return 2
|
||||
APP_TEAM=ZZZZZZZZZZ
|
||||
! install_pkg "$pkg"
|
||||
}
|
||||
|
||||
team_of() {
|
||||
codesign -dv "$(app_path "$1")" 2>&1 | sed -n 's/^TeamIdentifier=//p'
|
||||
}
|
||||
|
||||
nextcloud_opens() {
|
||||
open -a "$(app_path nextcloud)" --args --overrideserverurl https://nextcloud.smoke.invalid
|
||||
sleep 10
|
||||
pgrep -x Nextcloud > /dev/null
|
||||
}
|
||||
|
||||
scenario() {
|
||||
local app
|
||||
# The vanilla image turns Gatekeeper off; a real Mac has it on
|
||||
sudo spctl --global-enable 2> /dev/null || sudo spctl --master-enable 2> /dev/null
|
||||
check "Gatekeeper is on" gatekeeper_on
|
||||
gatekeeper_on || { skip "Gatekeeper couldn't be turned on, so the checks below prove less"; }
|
||||
check "Gatekeeper turns down an app no one notarized" unnotarized_refused
|
||||
check "install_pkg refuses a package signed by another Team ID" wrong_team_refused
|
||||
|
||||
for app in element nextcloud tailscale; do
|
||||
step "$app"
|
||||
check "app_install $app (its Team ID and notarization check out)" app_install "$app"
|
||||
app_info "$app"
|
||||
check_eq "$app's Team ID is the one in apps.sh" "$APP_TEAM" "$(team_of "$app")"
|
||||
done
|
||||
check "Nextcloud opens with the Core's address" nextcloud_opens
|
||||
pkill -x Nextcloud 2> /dev/null
|
||||
skip "Tailscale's VPN approval and Nextcloud's sign-in need clicks: check those by hand"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# shellcheck shell=bash
|
||||
DESCRIPTION="Network storage's launchd job: mounts on login and network changes, skips servers it can't reach"
|
||||
TIER=quick
|
||||
|
||||
source "$CONNECTOR/configure.d/60-storage.sh"
|
||||
UNREACHABLE="smb://smoke@nas.smoke.invalid/files"
|
||||
|
||||
job_loaded() {
|
||||
launchctl print "gui/$(id -u)/$LABEL" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
skips_quickly() {
|
||||
local start=$SECONDS
|
||||
bash "$STORAGE_MOUNT" || return 1
|
||||
[ $((SECONDS - start)) -le 10 ]
|
||||
}
|
||||
|
||||
lists_unmounted() {
|
||||
[ "$(bash "$STORAGE_MOUNT" --list)" = "$UNREACHABLE|" ]
|
||||
}
|
||||
|
||||
scenario() {
|
||||
mkdir -p "$CONF_DIR"
|
||||
: > "$STORAGE_CONF"
|
||||
check "record adds a share and the job" record "$UNREACHABLE" "/Volumes/files"
|
||||
check "launchd has the job" job_loaded
|
||||
check "the plist names the script" plutil -lint "$PLIST"
|
||||
check "a server it can't reach is skipped, quickly and without asking" skips_quickly
|
||||
check "--list shows it as not mounted" lists_unmounted
|
||||
check_not "mounted_at doesn't find it" mounted_at "$UNREACHABLE"
|
||||
check "remove_share" remove_share "$UNREACHABLE"
|
||||
check_not "the job is gone with the last share" job_loaded
|
||||
skip "Mounting a real share needs another machine and the sign-in window: check by hand"
|
||||
}
|
||||
Reference in New Issue
Block a user