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

55 lines
1.5 KiB
Bash

#!/usr/bin/env bats
# Unit tests for firewall configuration functions
# Add bats library to BATS_LIB_PATH
load 'bats-support/load'
load 'bats-assert/load'
load '../test_helper/common.bash'
@test "parse wireguard endpoint from config" {
# Create test configuration
local test_config="$TEST_TEMP_DIR/wg0.conf"
create_test_wg_config "$test_config"
# Source the firewall setup script functions
source "${PROJECT_ROOT}/src/firewall-setup.sh"
# Test parsing function
result=$(parse_wg_endpoint "$test_config")
assert_equal "$result" "192.168.1.100:51820"
}
@test "generate nftables rules for wireguard" {
source "${PROJECT_ROOT}/src/firewall-setup.sh"
rules=$(generate_nftables_rules "192.168.1.100:51820")
assert_regex "$rules" "udp.*192.168.1.100.*51820"
assert_regex "$rules" "policy drop"
}
@test "error handling for missing config file" {
source "${PROJECT_ROOT}/src/firewall-setup.sh"
run parse_wg_endpoint "/nonexistent/file.conf"
assert_failure
assert_output --partial "Error: WireGuard config not found"
}
@test "error handling for malformed config" {
# Create malformed config without endpoint
local malformed_config="$TEST_TEMP_DIR/malformed.conf"
cat > "$malformed_config" << EOF
[Interface]
PrivateKey = testkey
Address = 10.0.0.2/24
[Peer]
PublicKey = testpubkey
# No endpoint line
EOF
source "${PROJECT_ROOT}/src/firewall-setup.sh"
run parse_wg_endpoint "$malformed_config"
assert_failure
}