mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
42424b515b
Add ftl_api_port function Signed-off-by: Christian König <ckoenig@posteo.de> Use getFTLAPIPort in pihole Signed-off-by: Christian König <ckoenig@posteo.de> Use default portfile as fallback Signed-off-by: Christian König <ckoenig@posteo.de> Fix stickler Signed-off-by: Christian König <ckoenig@posteo.de> Correct variables Signed-off-by: Christian König <ckoenig@posteo.de> Apply suggestions from code review Co-authored-by: DL6ER <DL6ER@users.noreply.github.com> Add test getFTLAPIPort returing default port Signed-off-by: Christian König <ckoenig@posteo.de> Remove unused code from test_key_val_replacement_works Signed-off-by: Christian König <ckoenig@posteo.de> Add getFTLAPIPort_custom test Signed-off-by: Christian König <ckoenig@posteo.de> Fix output format Signed-off-by: Christian König <ckoenig@posteo.de> Add debugging Signed-off-by: Christian König <ckoenig@posteo.de> Remove debugging and fix function Signed-off-by: Christian König <ckoenig@posteo.de>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
def test_key_val_replacement_works(host):
|
|
''' Confirms addOrEditKeyValPair provides the expected output '''
|
|
host.run('''
|
|
source /opt/pihole/utils.sh
|
|
addOrEditKeyValPair "KEY_ONE" "value1" "./testoutput"
|
|
addOrEditKeyValPair "KEY_TWO" "value2" "./testoutput"
|
|
addOrEditKeyValPair "KEY_ONE" "value3" "./testoutput"
|
|
addOrEditKeyValPair "KEY_FOUR" "value4" "./testoutput"
|
|
''')
|
|
output = host.run('''
|
|
cat ./testoutput
|
|
''')
|
|
expected_stdout = 'KEY_ONE=value3\nKEY_TWO=value2\nKEY_FOUR=value4\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
|
|
''')
|
|
expected_stdout = '4711\n'
|
|
assert expected_stdout == output.stdout
|
|
|
|
|
|
def test_getFTLAPIPort_custom(host):
|
|
''' Confirms getFTLAPIPort returns a custom API port in a custom PORTFILE location '''
|
|
host.run('''
|
|
echo "PORTFILE=/tmp/port.file" > /etc/pihole/pihole-FTL.conf
|
|
echo "1234" > /tmp/port.file
|
|
''')
|
|
output = host.run('''
|
|
source /opt/pihole/utils.sh
|
|
getFTLAPIPort
|
|
''')
|
|
expected_stdout = '1234\n'
|
|
assert expected_stdout == output.stdout
|