mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-20 22:30:13 +00:00
No detour - use pihole-FTL.conf to get the API port number
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
1b0b0ca445
commit
3d01e4d0cf
4 changed files with 42 additions and 58 deletions
|
@ -62,50 +62,52 @@ def test_key_removal_works(host):
|
|||
assert expected_stdout == output.stdout
|
||||
|
||||
|
||||
def test_getFTLAPIPortFile_default(host):
|
||||
"""Confirms getFTLAPIPortFile returns the default API port file path"""
|
||||
output = host.run(
|
||||
"""
|
||||
source /opt/pihole/utils.sh
|
||||
getFTLAPIPortFile
|
||||
"""
|
||||
)
|
||||
expected_stdout = "/run/pihole-FTL.port\n"
|
||||
assert expected_stdout == output.stdout
|
||||
|
||||
|
||||
def test_getFTLAPIPort_default(host):
|
||||
"""Confirms getFTLAPIPort returns the default API port"""
|
||||
output = host.run(
|
||||
"""
|
||||
source /opt/pihole/utils.sh
|
||||
getFTLAPIPort "/run/pihole-FTL.port"
|
||||
getFTLAPIPort
|
||||
"""
|
||||
)
|
||||
expected_stdout = "4711\n"
|
||||
assert expected_stdout == output.stdout
|
||||
|
||||
|
||||
def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host):
|
||||
"""Confirms getFTLAPIPort returns a custom API port in a custom PORTFILE location"""
|
||||
def test_getFTLAPIPort_custom(host):
|
||||
"""Confirms getFTLAPIPort returns a custom API port"""
|
||||
host.run(
|
||||
"""
|
||||
tmpfile=$(mktemp)
|
||||
echo "PORTFILE=${tmpfile}" > /etc/pihole/pihole-FTL.conf
|
||||
echo "1234" > ${tmpfile}
|
||||
echo "FTLPORT=1234" > /etc/pihole/pihole-FTL.conf
|
||||
"""
|
||||
)
|
||||
output = host.run(
|
||||
"""
|
||||
source /opt/pihole/utils.sh
|
||||
FTL_API_PORT_FILE=$(getFTLAPIPortFile)
|
||||
getFTLAPIPort "${FTL_API_PORT_FILE}"
|
||||
getFTLAPIPort
|
||||
"""
|
||||
)
|
||||
expected_stdout = "1234\n"
|
||||
assert expected_stdout == output.stdout
|
||||
|
||||
|
||||
def test_getFTLAPIPort_malicious(host):
|
||||
"""Confirms getFTLAPIPort returns -1 if the setting in pihole-FTL.conf contains non-digits"""
|
||||
host.run(
|
||||
"""
|
||||
echo "FTLPORT=*$ssdfsd" > /etc/pihole/pihole-FTL.conf
|
||||
"""
|
||||
)
|
||||
output = host.run(
|
||||
"""
|
||||
source /opt/pihole/utils.sh
|
||||
getFTLAPIPort
|
||||
"""
|
||||
)
|
||||
expected_stdout = "-1\n"
|
||||
assert expected_stdout == output.stdout
|
||||
|
||||
|
||||
def test_getFTLPIDFile_default(host):
|
||||
"""Confirms getFTLPIDFile returns the default PID file path"""
|
||||
output = host.run(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue