mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-20 10:28:36 +00:00
Add web password support
This commit is contained in:
@@ -57,3 +57,23 @@ def test_debian_setup_php_env(Docker, tag, expected_lines, repeat_function):
|
||||
search_config_cmd = "grep -c '{}' /etc/lighttpd/conf-enabled/15-fastcgi-php.conf".format(expected_line)
|
||||
search_config_count = Docker.run(search_config_cmd)
|
||||
assert search_config_count.stdout.rstrip('\n') == '1'
|
||||
|
||||
@pytest.mark.parametrize('args,secure,setupVarsHash', [
|
||||
('-e ServerIP=1.2.3.4 -e WEBPASSWORD=login', True, 'WEBPASSWORD=6060d59351e8c2f48140f01b2c3f3b61652f396c53a5300ae239ebfbe7d5ff08'),
|
||||
('-e ServerIP=1.2.3.4 -e WEBPASSWORD=""', False, ''),
|
||||
('-e ServerIP=1.2.3.4', True, 'WEBPASSWORD='),
|
||||
])
|
||||
def test_webPassword_env_assigns_password_to_file(Docker, args, secure, setupVarsHash):
|
||||
''' When a user sets webPassword env the admin password gets set to that '''
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_password /start.sh`')
|
||||
if secure and 'WEBPASSWORD' not in args:
|
||||
assert 'Assigning random password' in function.stdout
|
||||
else:
|
||||
assert 'Assigning random password' not in function.stdout
|
||||
|
||||
if secure:
|
||||
assert 'New password set' in function.stdout
|
||||
assert Docker.run('grep -q \'{}\' {}'.format(setupVarsHash, '/etc/pihole/setupVars.conf')).rc == 0
|
||||
else:
|
||||
assert 'Password removed' in function.stdout
|
||||
assert Docker.run('grep -q \'^WEBPASSWORD=$\' /etc/pihole/setupVars.conf').rc == 0
|
||||
|
||||
Reference in New Issue
Block a user