mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-26 09:10:13 +00:00
REVISIT: Don't rely on existence of setupVars.conf
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
0e8f285f4f
commit
7cbe713873
5 changed files with 15 additions and 111 deletions
|
@ -4,13 +4,6 @@ import testinfra.backend.docker
|
|||
import subprocess
|
||||
from textwrap import dedent
|
||||
|
||||
|
||||
SETUPVARS = {
|
||||
"PIHOLE_INTERFACE": "eth99",
|
||||
"PIHOLE_DNS_1": "4.2.2.1",
|
||||
"PIHOLE_DNS_2": "4.2.2.2",
|
||||
}
|
||||
|
||||
IMAGE = "pytest_pihole:test_container"
|
||||
|
||||
tick_box = "[\x1b[1;32m\u2713\x1b[0m]"
|
||||
|
|
|
@ -2,7 +2,6 @@ import pytest
|
|||
from textwrap import dedent
|
||||
import re
|
||||
from .conftest import (
|
||||
SETUPVARS,
|
||||
tick_box,
|
||||
info_box,
|
||||
cross_box,
|
||||
|
@ -32,42 +31,6 @@ def test_supported_package_manager(host):
|
|||
# assert package_manager_detect.rc == 1
|
||||
|
||||
|
||||
def test_setupVars_are_sourced_to_global_scope(host):
|
||||
"""
|
||||
currently update_dialogs sources setupVars with a dot,
|
||||
then various other functions use the variables.
|
||||
This confirms the sourced variables are in scope between functions
|
||||
"""
|
||||
setup_var_file = "cat <<EOF> /etc/pihole/setupVars.conf\n"
|
||||
for k, v in SETUPVARS.items():
|
||||
setup_var_file += "{}={}\n".format(k, v)
|
||||
setup_var_file += "EOF\n"
|
||||
host.run(setup_var_file)
|
||||
|
||||
script = dedent(
|
||||
"""\
|
||||
set -e
|
||||
printSetupVars() {
|
||||
# Currently debug test function only
|
||||
echo "Outputting sourced variables"
|
||||
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
||||
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
||||
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
||||
}
|
||||
update_dialogs() {
|
||||
. /etc/pihole/setupVars.conf
|
||||
}
|
||||
update_dialogs
|
||||
printSetupVars
|
||||
"""
|
||||
)
|
||||
|
||||
output = run_script(host, script).stdout
|
||||
|
||||
for k, v in SETUPVARS.items():
|
||||
assert "{}={}".format(k, v) in output
|
||||
|
||||
|
||||
def test_selinux_not_detected(host):
|
||||
"""
|
||||
confirms installer continues when SELinux configuration file does not exist
|
||||
|
@ -116,12 +79,6 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||
host.run("command -v apt-get > /dev/null && apt-get install -qq man")
|
||||
host.run("command -v dnf > /dev/null && dnf install -y man")
|
||||
host.run("command -v yum > /dev/null && yum install -y man")
|
||||
# create configuration file
|
||||
setup_var_file = "cat <<EOF> /etc/pihole/setupVars.conf\n"
|
||||
for k, v in SETUPVARS.items():
|
||||
setup_var_file += "{}={}\n".format(k, v)
|
||||
setup_var_file += "EOF\n"
|
||||
host.run(setup_var_file)
|
||||
install = host.run(
|
||||
"""
|
||||
export TERM=xterm
|
||||
|
@ -185,10 +142,6 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||
check_FTLconf = test_cmd.format("w", "/etc/pihole/pihole-FTL.conf", piholeuser)
|
||||
actual_rc = host.run(check_FTLconf).rc
|
||||
assert exit_status_success == actual_rc
|
||||
# readable setupVars.conf
|
||||
check_setup = test_cmd.format("r", "/etc/pihole/setupVars.conf", piholeuser)
|
||||
actual_rc = host.run(check_setup).rc
|
||||
assert exit_status_success == actual_rc
|
||||
# check readable and executable /etc/init.d/pihole-FTL
|
||||
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
|
||||
actual_rc = host.run(check_init).rc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue