Files
football/tests/unit/encryption-validation_test.bats
T
mrcharles c1d8c5def6 chore: clean up root directory and consolidate documentation
Remove obsolete documentation files and consolidate into docs/ directory. Remove redundant test scripts (functionality will be folded into run.sh). Update AGENTS.md with SDLC workflow. Update PRD.md with tier0 architecture clarification. Update README.md to reflect clean directory structure.

Changes:
- Delete: BUILD-COMPLETE.md, BUILD-SUMMARY.md, RESUME.md, SESSION-CLOSED.md
- Delete: FINAL-SECURITY-COMPLIANCE-REPORT.md, QUICK_START.md, JOURNAL.md
- Move: TEST-COVERAGE.md, VERIFICATION-REPORT.md to docs/
- Delete: test-iso.sh, test-runner.sh (will fold into run.sh)
- Update: AGENTS.md with SDLC workflow section
- Update: PRD.md with tier0 architecture clarification and diagram
- Update: README.md to reflect clean directory structure

Root directory now contains only: AGENTS.md, README.md, PRD.md, Dockerfile, run.sh

💘 Generated with Crush

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

77 lines
2.5 KiB
Bash

#!/usr/bin/env bats
# Comprehensive unit tests for encryption-validation.sh hook
# Add bats library to BATS_LIB_PATH
load 'bats-support/load'
load 'bats-assert/load'
load 'bats-file/load'
load '../test_helper/common.bash'
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
}