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.
38 lines
1.7 KiB
Bash
38 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
# shellcheck shell=bash
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
TEST_NAME="test_validation"
|
|
phoebus_test_setup
|
|
|
|
assert_success "valid hostname" validate_hostname "phoebus"
|
|
assert_success "hostname with hyphen" validate_hostname "my-box"
|
|
assert_failure "hostname with space" validate_hostname "bad host"
|
|
assert_failure "empty hostname" validate_hostname ""
|
|
assert_failure "hostname leading -" validate_hostname "-bad"
|
|
|
|
assert_success "valid username" validate_username "alice"
|
|
assert_failure "root refused" validate_username "root"
|
|
assert_failure "uppercase username" validate_username "Alice"
|
|
assert_failure "empty username" validate_username ""
|
|
|
|
assert_success "valid timezone" validate_timezone "UTC"
|
|
assert_failure "empty timezone" validate_timezone ""
|
|
|
|
assert_failure "target not a block device" validate_target_disk "/dev/does-not-exist-xyz"
|
|
assert_failure "empty target" validate_target_disk ""
|
|
|
|
assert_success "sr0 protected" disks_is_protected "/dev/sr0"
|
|
assert_success "loop protected" disks_is_protected "/dev/loop0"
|
|
|
|
assert_eq "weak" "$(validate_password_strength "abc")" "short password weak"
|
|
assert_eq "weak" "$(validate_password_strength "abcdefghij")" "10 lowercase chars weak"
|
|
assert_eq "fair" "$(validate_password_strength "Abcdefghij")" "mixed-case password fair"
|
|
assert_eq "strong" "$(validate_password_strength "Abcdef1!ghijk")" "complex password strong"
|
|
|
|
# validate_config reports missing required fields
|
|
config_set HOSTNAME "ok-host"
|
|
config_set USERNAME ""
|
|
problems="$(validate_config HOSTNAME USERNAME)"
|
|
assert_contains "$problems" "username" "validate_config flags missing username"
|
|
|
|
phoebus_test_report
|