Initial public import of the proven Bash installer (installer/) and the production Rust workspace (installer-rs/). The reference ISO, build output and local agent transcripts are gitignored. Verified: installer/tests/run_tests.sh and cargo test --workspace both pass.
31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
#!/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
|