mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2026-04-28 12:44:09 +01:00
Adding custom web port with tests
This commit is contained in:
@@ -21,6 +21,31 @@ def test_IPv6_not_True_removes_ipv6(Docker, os, args, expected_ipv6, expected_st
|
||||
config = Docker.run('cat {}'.format( WEB_CONFIG[os])).stdout
|
||||
assert (IPV6_LINE[os] in config) == expected_ipv6
|
||||
|
||||
@pytest.mark.parametrize('args', [DEFAULTARGS + '-e "WEB_PORT=999"'])
|
||||
def test_overrides_default_WEB_PORT(Docker, os, args):
|
||||
''' When a --net=host user sets WEB_PORT to avoid synology's 80 default IPv4 and or IPv6 ports are updated'''
|
||||
CONFIG_LINES = { 'alpine': ['listen 999 default_server',
|
||||
'listen\s*\[::\]:999\s*default_server;'],
|
||||
'debian': ['server.port\s*=\s*999'] }
|
||||
WEB_CONFIG = { 'alpine': '/etc/nginx/nginx.conf',
|
||||
'debian': '/etc/lighttpd/lighttpd.conf' }
|
||||
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_port /start.sh`')
|
||||
assert "Custom WEB_PORT set to 999" in function.stdout
|
||||
assert "INFO: Without proper router DNAT forwarding to 127.0.0.1:999, you may not get any blocked websites on ads" in function.stdout
|
||||
config = Docker.run('cat {}'.format( WEB_CONFIG[os])).stdout
|
||||
for expected_line in CONFIG_LINES[os]:
|
||||
assert re.search(expected_line, config) != None
|
||||
|
||||
@pytest.mark.parametrize('args,expected_error', [
|
||||
(DEFAULTARGS + '-e WEB_PORT="LXXX"', 'WARNING: Custom WEB_PORT not used - LXXX is not an integer'),
|
||||
(DEFAULTARGS + '-e WEB_PORT="1,000"', 'WARNING: Custom WEB_PORT not used - 1,000 is not an integer'),
|
||||
(DEFAULTARGS + '-e WEB_PORT="99999"', 'WARNING: Custom WEB_PORT not used - 99999 is not within valid port range of 1-65535'),
|
||||
])
|
||||
def test_bad_input_to_WEB_PORT(Docker, args, expected_error):
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_port /start.sh`')
|
||||
assert expected_error in function.stdout
|
||||
|
||||
@pytest.mark.parametrize('args, expected_stdout, dns1, dns2', [
|
||||
('-e ServerIP="1.2.3.4"', 'default DNS', '8.8.8.8', '8.8.4.4' ),
|
||||
('-e ServerIP="1.2.3.4" -e DNS1="1.2.3.4"', 'custom DNS', '1.2.3.4', '8.8.4.4' ),
|
||||
|
||||
Reference in New Issue
Block a user