Add web password support

This commit is contained in:
diginc
2017-02-08 22:46:46 -06:00
parent 0eb410ae31
commit 907d36ae9b
4 changed files with 30 additions and 1 deletions

View File

@@ -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