various test fixes

This commit is contained in:
diginc
2017-01-10 20:38:42 -06:00
parent 2a973ed0e1
commit 136f43a995
4 changed files with 16 additions and 12 deletions

View File

@@ -4,9 +4,9 @@ mkdir -p /etc/pihole/
# Make pihole scripts fail searching for `systemctl`, # Make pihole scripts fail searching for `systemctl`,
# which fails pretty miserably in docker compared to `service` # which fails pretty miserably in docker compared to `service`
# For more info see docker/docker issue #7459 # For more info see docker/docker issue #7459
mv `which systemctl` /bin/no_systemctl && \ mv "$(which systemctl)" /bin/no_systemctl && \
# debconf-apt-progress seems to hang so get rid of it too # debconf-apt-progress seems to hang so get rid of it too
mv `which debconf-apt-progress` /bin/no_debconf-apt-progress mv "$(which debconf-apt-progress)" /bin/no_debconf-apt-progress
# Get the install functions # Get the install functions
wget -O "$PIHOLE_INSTALL" https://install.pi-hole.net wget -O "$PIHOLE_INSTALL" https://install.pi-hole.net
@@ -14,14 +14,15 @@ if [[ "$IMAGE" == 'alpine' ]] ; then
sed -i '/OS distribution not supported/ i\ echo "Hi Alpine"' "$PIHOLE_INSTALL" sed -i '/OS distribution not supported/ i\ echo "Hi Alpine"' "$PIHOLE_INSTALL"
sed -i '/OS distribution not supported/,+1d' "$PIHOLE_INSTALL" sed -i '/OS distribution not supported/,+1d' "$PIHOLE_INSTALL"
sed -i 's#nologin pihole#nologin pihole 2>/dev/null || adduser -S -s /sbin/nologin pihole#g' "$PIHOLE_INSTALL" sed -i 's#nologin pihole#nologin pihole 2>/dev/null || adduser -S -s /sbin/nologin pihole#g' "$PIHOLE_INSTALL"
# shellcheck disable=SC2016
sed -i '/usermod -a -G/ s#$# 2> /dev/null || addgroup pihole ${LIGHTTPD_GROUP}#g' "$PIHOLE_INSTALL" sed -i '/usermod -a -G/ s#$# 2> /dev/null || addgroup pihole ${LIGHTTPD_GROUP}#g' "$PIHOLE_INSTALL"
sed -i 's/www-data/nginx/g' "$PIHOLE_INSTALL" sed -i 's/www-data/nginx/g' "$PIHOLE_INSTALL"
sed -i '/LIGHTTPD_CFG/d' "${PIHOLE_INSTALL}" sed -i '/LIGHTTPD_CFG/d' "${PIHOLE_INSTALL}"
sed -i '/etc\/cron.d\//d' "${PIHOLE_INSTALL}" sed -i '/etc\/cron.d\//d' "${PIHOLE_INSTALL}"
LIGHTTPD_USER="nginx" LIGHTTPD_USER="nginx" # shellcheck disable=SC2034
LIGHTTPD_GROUP="nginx" LIGHTTPD_GROUP="nginx" # shellcheck disable=SC2034
LIGHTTPD_CFG="lighttpd.conf.debian" LIGHTTPD_CFG="lighttpd.conf.debian" # shellcheck disable=SC2034
DNSMASQ_USER="dnsmasq" DNSMASQ_USER="dnsmasq" # shellcheck disable=SC2034
fi fi
PH_TEST=true . "${PIHOLE_INSTALL}" PH_TEST=true . "${PIHOLE_INSTALL}"

View File

@@ -1,5 +1,5 @@
docker-compose docker-compose
pytest pytest==2.9.2
pytest-xdist pytest-cov==2.3.0
pytest-cov pytest-xdist==1.14
testinfra testinfra==1.5.1

View File

@@ -9,7 +9,7 @@ run_local = testinfra.get_backend(
@pytest.mark.parametrize("upstream,image,tag", [ @pytest.mark.parametrize("upstream,image,tag", [
( 'alpine:edge', 'alpine.docker', 'diginc/pi-hole:alpine' ), ( 'alpine:edge', 'alpine.docker', 'diginc/pi-hole:alpine' ),
( 'debian:jessie', 'debian.docker', 'diginc/pi-hole:debian' ), ( 'debian:jessie', 'debian.docker', 'diginc/pi-hole:debian' ),
( 'jsurf/rpi-raspbian', 'debian-armhf.docker', 'diginc/pi-hole:arm' ), #( 'jsurf/rpi-raspbian', 'debian-armhf.docker', 'diginc/pi-hole:arm' ),
]) ])
def test_build_pihole_image(upstream, image, tag): def test_build_pihole_image(upstream, image, tag):
run_local('docker pull {}'.format(upstream)) run_local('docker pull {}'.format(upstream))

View File

@@ -38,7 +38,10 @@ def test_indecies_are_present(RunningPiHole):
File('/var/www/html/pihole/index.html').exists File('/var/www/html/pihole/index.html').exists
File('/var/www/html/pihole/index.js').exists File('/var/www/html/pihole/index.js').exists
@pytest.mark.parametrize('ip', [ '127.0.0.1', '[::]' ] ) @pytest.mark.parametrize('ip,args', [
('127.0.0.1', '-e ServerIP="192.168.100.2" -e VIRTUAL_HOST="127.0.0.1"'),
('[::]', '-e ServerIP="192.168.100.2" -e VIRTUAL_HOST="[::]"')
])
@pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] ) @pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] )
def test_html_index_requests_load_as_expected(RunningPiHole, ip, url): def test_html_index_requests_load_as_expected(RunningPiHole, ip, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(ip, url) command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(ip, url)