Files
football/tests/unit/encryption-validation_test.bats
ReachableCEO c1505a9940 chore: remove obsolete scripts and clean project structure
Remove obsolete script files that are no longer needed. Root run.sh has all functionality. Clean src/ directory to only contain necessary source scripts.

Deleted files:
- bin/cleanup.sh (functionality in run.sh)
- bin/docker-manage.sh (functionality in run.sh)
- lib/docker.sh (not used, deleted)
- src/build.sh (obsolete, not referenced)
- src/run.sh (obsolete, duplicate of root run.sh)
- src/run-new.sh (broken, references deleted lib/docker.sh)
- plan/PreFlightDiscussion-*.md (planning docs no longer needed)

Modified files:
- .gitignore - Added Docker build artifacts (bin/, lib/, plan/)
- tests/test_helper/common.bash - Fixed for standalone execution

Current src/ directory (essential scripts only):
- build-iso.sh - ISO build orchestration
- firewall-setup.sh - Firewall configuration
- security-hardening.sh - Security hardening functions

💘 Generated with Crush

Assisted-by: GLM-4.7 via Crush <crush@charm.land>
2026-01-29 12:42:51 -05:00

73 lines
2.4 KiB
Bash

#!/usr/bin/env bats
# Comprehensive unit tests for encryption-validation.sh hook
# Add bats library to BATS_LIB_PATH
setup() {
export TEST_ROOT="${TEST_TEMP_DIR}/encryption-validation"
mkdir -p "${TEST_ROOT}"
}
@test "encryption-validation.sh exists and is executable" {
assert_file_exists "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
assert [ -x "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh" ]
}
@test "encryption-validation.sh validates encryption configuration" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
# Mock cryptsetup
cryptsetup() {
echo "cryptsetup $@"
return 0
}
export -f cryptsetup
local config_file="${TEST_ROOT}/crypttab"
echo "sda1_crypt UUID=12345678-1234-1234-1234-123456789012 none luks" > "$config_file"
validate_encryption_config "$config_file"
assert_success
}
@test "encryption-validation.sh creates user reminder file" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
local home_dir="${TEST_ROOT}/home/user"
mkdir -p "$home_dir"
create_encryption_reminder "$home_dir"
assert_file_exists "$home_dir/ENCRYPTION-PASSPHRASE-REMINDER.txt"
assert_file_contains "$home_dir/ENCRYPTION-PASSPHRASE-REMINDER.txt" "Full Disk Encryption"
assert_file_contains "$home_dir/ENCRYPTION-PASSPHRASE-REMINDER.txt" "LUKS2"
assert_file_contains "$home_dir/ENCRYPTION-PASSPHRASE-REMINDER.txt" "14+ characters"
}
@test "encryption-validation.sh creates MOTD messages" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
local motd_dir="${TEST_ROOT}/motd.d"
mkdir -p "$motd_dir"
setup_encryption_motd "$motd_dir"
assert_file_exists "$motd_dir/10-encryption-status"
assert_file_contains "$motd_dir/10-encryption-status" "Full Disk Encryption"
}
@test "encryption-validation.sh creates first boot check" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
local local_bin="${TEST_ROOT}/bin"
mkdir -p "$local_bin"
create_first_boot_check "$local_bin"
assert_file_exists "$local_bin/first-boot-encryption-check.sh"
assert [ -x "$local_bin/first-boot-encryption-check.sh" ]
}
@test "encryption-validation.sh script is valid bash" {
run bash -n "${PROJECT_ROOT}/config/hooks/installed/encryption-validation.sh"
assert_success
}