fix [this code smell](https://sonarcloud.io/project/issues?pullRequest=1106&issues=AYE6byrIbM3H9G6ifn9K&open=AYE6byrIbM3H9G6ifn9K&id=pi-hole_docker-pi-hole)
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
6b9a4e6216
commit
64e449c133
|
@ -178,9 +178,12 @@ def test_debian_setup_php_env(Docker, expected_lines, repeat_function):
|
|||
assert False, f'Found line {expected_line} times (more than once): {found_lines}'
|
||||
|
||||
|
||||
WEBPASSWORD_TEST_FUNCTION_COMMAND='. /bash_functions.sh ; eval `grep setup_web_password /start.sh`'
|
||||
|
||||
|
||||
def test_webPassword_random_generation(Docker):
|
||||
''' 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`')
|
||||
function = Docker.run(WEBPASSWORD_TEST_FUNCTION_COMMAND)
|
||||
assert 'assigning random password' in function.stdout.lower()
|
||||
|
||||
|
||||
|
@ -191,7 +194,7 @@ def test_webPassword_random_generation(Docker):
|
|||
])
|
||||
def test_webPassword_env_assigns_password_to_file_or_removes_if_empty(Docker, args_env, secure, setupVarsHash):
|
||||
''' When a user sets webPassword env the admin password gets set or removed if empty '''
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_password /start.sh`')
|
||||
function = Docker.run(WEBPASSWORD_TEST_FUNCTION_COMMAND)
|
||||
|
||||
if secure:
|
||||
assert 'new password set' in function.stdout.lower()
|
||||
|
@ -205,7 +208,7 @@ def test_webPassword_env_assigns_password_to_file_or_removes_if_empty(Docker, ar
|
|||
@pytest.mark.parametrize('test_args', ['-e WEBPASSWORD=login', '-e WEBPASSWORD=""'])
|
||||
def test_env_always_updates_password(Docker, args_env, test_args):
|
||||
'''When a user sets the WEBPASSWORD environment variable, ensure it always sets the password'''
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_password /start.sh`')
|
||||
function = Docker.run(WEBPASSWORD_TEST_FUNCTION_COMMAND)
|
||||
|
||||
assert '::: Assigning password defined by Environment Variable' in function.stdout
|
||||
|
||||
|
@ -214,7 +217,7 @@ def test_env_always_updates_password(Docker, args_env, test_args):
|
|||
def test_setupvars_trumps_random_password_if_set(Docker, args_env, test_args):
|
||||
'''If a password is already set in setupVars, and no password is set in the environment variable, do not generate a random password'''
|
||||
Docker.run('. /opt/pihole/utils.sh ; addOrEditKeyValPair /etc/pihole/setupVars.conf WEBPASSWORD volumepass')
|
||||
function = Docker.run('. /bash_functions.sh ; eval `grep setup_web_password /start.sh`')
|
||||
function = Docker.run(WEBPASSWORD_TEST_FUNCTION_COMMAND)
|
||||
|
||||
assert 'Pre existing WEBPASSWORD found' in function.stdout
|
||||
assert Docker.run('grep -q \'{}\' {}'.format('WEBPASSWORD=volumepass', '/etc/pihole/setupVars.conf')).rc == 0
|
||||
|
|
Loading…
Reference in New Issue