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

78 lines
2.3 KiB
Bash

#!/usr/bin/env bats
# Comprehensive unit tests for encryption-setup.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-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
}