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>
52 lines
1.4 KiB
Bash
52 lines
1.4 KiB
Bash
#!/usr/bin/env bats
|
|
# Unit tests for firewall configuration functions
|
|
|
|
# Add bats library to BATS_LIB_PATH
|
|
|
|
|
|
@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
|
|
} |