mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2026-04-19 16:31:01 +01:00
Add tests for areas of container behaviour not previously exercised: - crond is running (not just that the crontab file is valid) - Logrotate config is installed at /etc/pihole/logrotate - Default DNS upstreams (8.8.8.8/8.8.4.4) applied when none configured - Web interface accessible at /admin/ (default port and custom port) - /pihole.docker.tag build metadata file is present - macvendor.db is present and configured in FTL - FTL is running as the pihole user (validates DNSMASQ_USER default) - Capabilities are applied to pihole-FTL (validates fix_capabilities) - WEBPASSWORD_FILE reads the web password from a Docker secret Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Adam Warner <me@adamwarner.co.uk>
33 lines
913 B
Bash
33 lines
913 B
Bash
#!/usr/bin/env bats
|
|
|
|
load 'libs/bats-support/load'
|
|
load 'libs/bats-assert/load'
|
|
load 'helpers.sh'
|
|
|
|
setup_file() {
|
|
# Create a temporary file to act as the Docker secret
|
|
local secret_file
|
|
secret_file=$(mktemp)
|
|
echo -n "mysecretpassword" > "$secret_file"
|
|
export SECRET_FILE="$secret_file"
|
|
|
|
CONTAINER=$(start_container \
|
|
-e WEBPASSWORD_FILE=pihole_password \
|
|
-v "${secret_file}:/run/secrets/pihole_password:ro")
|
|
wait_for_log "$CONTAINER" "########## FTL started"
|
|
export CONTAINER
|
|
}
|
|
|
|
teardown_file() {
|
|
docker rm -f "$CONTAINER" > /dev/null 2>&1 || true
|
|
rm -f "$SECRET_FILE"
|
|
}
|
|
|
|
# ---- Docker secrets ---------------------------------------------------------
|
|
|
|
@test "WEBPASSWORD_FILE reads the web password from a Docker secret" {
|
|
run docker logs "$CONTAINER"
|
|
assert_success
|
|
assert_output --partial "Setting FTLCONF_webserver_api_password from file"
|
|
}
|