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.
37 lines
1.3 KiB
Bash
37 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
TEST_NAME="test_state"
|
|
phoebus_test_setup
|
|
|
|
assert_eq "phoebus" "$(config_get HOSTNAME)" "default hostname"
|
|
|
|
config_set HOSTNAME "testbox"
|
|
assert_eq "testbox" "$(config_get HOSTNAME)" "config_set updates value"
|
|
|
|
config_default HOSTNAME "should-not-apply"
|
|
assert_eq "testbox" "$(config_get HOSTNAME)" "config_default does not override"
|
|
|
|
config_set SECRET_KEY "s3cr3t"
|
|
config_set USERNAME "alice"
|
|
|
|
local_file="$STATE_DIR/state.conf"
|
|
config_save_file "$local_file"
|
|
assert_success "config file written" test -s "$local_file"
|
|
|
|
config_set HOSTNAME "changed"
|
|
config_load_file "$local_file"
|
|
assert_eq "testbox" "$(config_get HOSTNAME)" "round-trip restores value"
|
|
assert_eq "alice" "$(config_get USERNAME)" "round-trip restores username"
|
|
|
|
assert_not_contains "$(cat "$local_file")" "PASSWORD" "secret keys with PASSWORD are not saved"
|
|
|
|
# redaction
|
|
secret_register "hunter2"
|
|
secret_register "topsecret"
|
|
assert_eq "pw=<redacted>" "$(redact_scrub "pw=hunter2")" "registered secret is scrubbed"
|
|
assert_eq "x" "$(redact_scrub "x")" "normal text unchanged"
|
|
assert_eq "<redacted>" "$(redact_value USER_PASSWORD "abc")" "redact_value hides password"
|
|
assert_eq "abc" "$(redact_value HOSTNAME "abc")" "redact_value keeps non-secret"
|
|
|
|
phoebus_test_report
|