Files
football/tests/unit/encryption-setup_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

74 lines
2.2 KiB
Bash

#!/usr/bin/env bats
# Comprehensive unit tests for encryption-setup.sh hook
# Add bats library to BATS_LIB_PATH
setup() {
export TEST_ROOT="${TEST_TEMP_DIR}/encryption-setup"
mkdir -p "${TEST_ROOT}"
}
@test "encryption-setup.sh exists and is executable" {
assert_file_exists "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
assert [ -x "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh" ]
}
@test "encryption-setup.sh creates LUKS2 configuration" {
# Source the script
source "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
# Mock cryptsetup
cryptsetup() {
echo "cryptsetup $@"
return 0
}
export -f cryptsetup
# Create test config
local config_file="${TEST_ROOT}/crypttab"
create_luks2_config "$config_file"
assert_file_exists "$config_file"
assert_file_contains "$config_file" "luks"
}
@test "encryption-setup.sh configures cryptsetup-initramfs" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
local config_file="${TEST_ROOT}/initramfs.conf"
configure_cryptsetup_initramfs "$config_file"
assert_file_exists "$config_file"
}
@test "encryption-setup.sh creates key management scripts" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
local script_dir="${TEST_ROOT}/scripts"
mkdir -p "$script_dir"
create_check_encryption_script "$script_dir/check-encryption.sh"
assert_file_exists "$script_dir/check-encryption.sh"
assert [ -x "$script_dir/check-encryption.sh" ]
create_manage_keys_script "$script_dir/manage-encryption-keys.sh"
assert_file_exists "$script_dir/manage-encryption-keys.sh"
assert [ -x "$script_dir/manage-encryption-keys.sh" ]
}
@test "encryption-setup.sh creates systemd service" {
source "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
local systemd_dir="${TEST_ROOT}/systemd"
mkdir -p "$systemd_dir"
create_encryption_service "$systemd_dir"
assert_file_exists "$systemd_dir/knel-encryption-status.service"
}
@test "encryption-setup.sh script is valid bash" {
run bash -n "${PROJECT_ROOT}/config/hooks/installed/encryption-setup.sh"
assert_success
}