#!/usr/bin/env bash # shellcheck shell=bash source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" TEST_NAME="test_safety" phoebus_test_setup # confirm.sh and install.sh are not loaded by lib.sh; load them explicitly. source "$PHOEBUS_ROOT/lib/confirm.sh" source "$PHOEBUS_ROOT/lib/install.sh" # destructive commands are blocked until authorized destructive_revoke assert_failure "run_destructive blocked when unauthorized" run_destructive "test op" true # after authorization, dry-run still prevents execution config_set DRY_RUN "yes" destructive_grant assert_success "run_destructive allowed after grant (dry-run)" run_destructive "test op" /bin/true destructive_revoke # effective root is a sandbox in dry-run, never the configured target config_set INSTALL_ROOT "/mnt/do-not-touch" config_set DRY_RUN "yes" root="$(install_effective_root)" assert_neq "/mnt/do-not-touch" "$root" "dry-run uses a sandbox root" assert_contains "$root" "dry-run-root" "sandbox root name is explicit" # in a real run the configured root is used config_set DRY_RUN "no" assert_eq "/mnt/do-not-touch" "$(install_effective_root)" "real root used when not dry-run" phoebus_test_report