Some checks are pending
CodeQL / Analyze (pull_request) Waiting to run
Test Supported Distributions / smoke-tests (pull_request) Waiting to run
Test Supported Distributions / distro-test (alpine_3_21) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_23) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_10) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_9) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_11) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_12) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_13) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_40) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_41) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_42) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_43) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_20) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_24) (pull_request) Blocked by required conditions
test_automated_install.bats was a single 372-line file running 18 tests serially, which doubled wall-clock CI time compared to the old pytest suite (which used pytest-xdist -n auto for parallelism). Split into three focused files: - test_automated_install.bats — core installer: package manager detection, SELinux config check, fresh install, package cache update (success/failure), dependency installation, meta-package uninstall (7 tests) - test_ftl.bats — FTL architecture detection for all supported arches plus binary installation and version check (9 tests) - test_network.bats — IPv6 address detection (link-local/ULA/GUA precedence) and IP address validation (6 tests) Update run.sh to include the new files and to pass --jobs $(nproc) to BATS when GNU parallel is available, running all files concurrently. This restores the degree of parallelism previously provided by pytest-xdist and brings CI duration back in line with the old suite. Signed-off-by: Adam Warner <me@adamwarner.co.uk>
117 lines
3.5 KiB
Bash
Executable File
117 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
# Network detection tests — IPv6 address detection and IP validation
|
|
|
|
load 'libs/bats-support/load'
|
|
load 'libs/bats-assert/load'
|
|
load 'helpers/mocks'
|
|
|
|
CID=""
|
|
|
|
setup() {
|
|
CID=$(docker run -d -t --cap-add=ALL "$IMAGE_TAG")
|
|
}
|
|
|
|
teardown() {
|
|
if [[ -n "$CID" ]]; then
|
|
docker rm -f "$CID" > /dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# IPv6 detection
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@test "IPv6 link-local only: blocking disabled" {
|
|
mock_command_2 "$CID" ip \
|
|
"-6 address" "inet6 fe80::d210:52fa:fe00:7ad7/64 scope link" "0"
|
|
run docker exec "$CID" bash -c "
|
|
source /opt/pihole/basic-install.sh
|
|
find_IPv6_information
|
|
"
|
|
assert_output --partial "Unable to find IPv6 ULA/GUA address"
|
|
}
|
|
|
|
@test "IPv6 ULA only: blocking enabled" {
|
|
mock_command_2 "$CID" ip \
|
|
"-6 address" "inet6 fda2:2001:5555:0:d210:52fa:fe00:7ad7/64 scope global" "0"
|
|
run docker exec "$CID" bash -c "
|
|
source /opt/pihole/basic-install.sh
|
|
find_IPv6_information
|
|
"
|
|
assert_output --partial "Found IPv6 ULA address"
|
|
}
|
|
|
|
@test "IPv6 GUA only: blocking enabled" {
|
|
mock_command_2 "$CID" ip \
|
|
"-6 address" "inet6 2003:12:1e43:301:d210:52fa:fe00:7ad7/64 scope global" "0"
|
|
run docker exec "$CID" bash -c "
|
|
source /opt/pihole/basic-install.sh
|
|
find_IPv6_information
|
|
"
|
|
assert_output --partial "Found IPv6 GUA address"
|
|
}
|
|
|
|
@test "IPv6 GUA + ULA: ULA takes precedence" {
|
|
mock_command_2 "$CID" ip \
|
|
"-6 address" "inet6 2003:12:1e43:301:d210:52fa:fe00:7ad7/64 scope global
|
|
inet6 fda2:2001:5555:0:d210:52fa:fe00:7ad7/64 scope global" "0"
|
|
run docker exec "$CID" bash -c "
|
|
source /opt/pihole/basic-install.sh
|
|
find_IPv6_information
|
|
"
|
|
assert_output --partial "Found IPv6 ULA address"
|
|
}
|
|
|
|
@test "IPv6 ULA + GUA: ULA takes precedence" {
|
|
mock_command_2 "$CID" ip \
|
|
"-6 address" "inet6 fda2:2001:5555:0:d210:52fa:fe00:7ad7/64 scope global
|
|
inet6 2003:12:1e43:301:d210:52fa:fe00:7ad7/64 scope global" "0"
|
|
run docker exec "$CID" bash -c "
|
|
source /opt/pihole/basic-install.sh
|
|
find_IPv6_information
|
|
"
|
|
assert_output --partial "Found IPv6 ULA address"
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# IP address validation
|
|
# ---------------------------------------------------------------------------
|
|
|
|
@test "valid_ip accepts and rejects addresses correctly" {
|
|
_valid() {
|
|
run docker exec "$CID" bash -c "source /opt/pihole/basic-install.sh; valid_ip '${1}'"
|
|
assert_success
|
|
}
|
|
_invalid() {
|
|
run docker exec "$CID" bash -c "source /opt/pihole/basic-install.sh; valid_ip '${1}'"
|
|
assert_failure
|
|
}
|
|
|
|
_valid "192.168.1.1"
|
|
_valid "127.0.0.1"
|
|
_valid "255.255.255.255"
|
|
_invalid "255.255.255.256"
|
|
_invalid "255.255.256.255"
|
|
_invalid "255.256.255.255"
|
|
_invalid "256.255.255.255"
|
|
_invalid "1092.168.1.1"
|
|
_invalid "not an IP"
|
|
_invalid "8.8.8.8#"
|
|
_valid "8.8.8.8#0"
|
|
_valid "8.8.8.8#1"
|
|
_valid "8.8.8.8#42"
|
|
_valid "8.8.8.8#888"
|
|
_valid "8.8.8.8#1337"
|
|
_valid "8.8.8.8#65535"
|
|
_invalid "8.8.8.8#65536"
|
|
_invalid "8.8.8.8#-1"
|
|
_invalid "00.0.0.0"
|
|
_invalid "010.0.0.0"
|
|
_invalid "001.0.0.0"
|
|
_invalid "0.0.0.0#00"
|
|
_invalid "0.0.0.0#01"
|
|
_invalid "0.0.0.0#001"
|
|
_invalid "0.0.0.0#0001"
|
|
_invalid "0.0.0.0#00001"
|
|
}
|