# 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" }