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.
36 lines
1.8 KiB
Bash
36 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
TEST_NAME="test_ai"
|
|
phoebus_test_setup
|
|
|
|
parsed="$(ai_parse_json_kv '{"hostname":"foo","encryption":"luks2","count":3}')"
|
|
assert_contains "$parsed" "hostname=foo" "flat JSON parser: string"
|
|
assert_contains "$parsed" "encryption=luks2" "flat JSON parser: string 2"
|
|
assert_contains "$parsed" "count=3" "flat JSON parser: number"
|
|
|
|
assert_success "HOSTNAME permitted" ai_key_allowed HOSTNAME
|
|
assert_failure "EVIL key refused" ai_key_allowed EVIL
|
|
assert_failure "LUKS_PASSPHRASE refused" ai_key_allowed LUKS_PASSPHRASE
|
|
|
|
assert_eq "" "$(ai_validate_field ENCRYPTION luks2)" "valid encryption accepted"
|
|
assert_neq "" "$(ai_validate_field ENCRYPTION bogus)" "invalid encryption rejected"
|
|
assert_neq "" "$(ai_validate_field HOSTNAME 'bad host')" "invalid hostname rejected"
|
|
assert_neq "" "$(ai_validate_field TARGET_DISK /dev/nonexistent)" "invalid disk rejected"
|
|
|
|
# applying a proposal with an out-of-whitelist key still validates known keys
|
|
before="$(config_get HOSTNAME)"
|
|
ai_apply_proposal '{"hostname":"good-host","evil":"rm -rf /"}' >/dev/null 2>&1 || true
|
|
assert_eq "good-host" "$(config_get HOSTNAME)" "valid proposal field applied"
|
|
assert_eq "" "$(config_get EVIL)" "unknown proposal field ignored"
|
|
|
|
# offline translator
|
|
offline="$(ai_propose_offline "encrypt everything with btrfs and a desktop")"
|
|
assert_contains "$offline" '"encryption":"luks2"' "offline proposal sets luks2"
|
|
assert_contains "$offline" '"filesystem":"btrfs"' "offline proposal sets btrfs"
|
|
assert_contains "$offline" '"desktop_profile":"dwl"' "offline proposal sets desktop"
|
|
|
|
# offline assistance never needs a model
|
|
assert_contains "$(ai_offline_response "encryption")" "LUKS2" "offline encryption help"
|
|
|
|
phoebus_test_report
|