fix stickler errors

Signed-off-by: pvogt09 <50047961+pvogt09@users.noreply.github.com>
This commit is contained in:
pvogt09 2020-04-03 19:22:30 +02:00
parent a993b8b34d
commit 25c5661c1b

View file

@ -96,6 +96,7 @@ def test_pihole_user_group_creation(Pihole):
''' '''
check user creation works if user or group already exist check user creation works if user or group already exist
''' '''
sudo_cmd = 'su --shell /bin/bash --command "{0}" -p root'
# normal situation where neither user or group exist # normal situation where neither user or group exist
user_create = Pihole.run(''' user_create = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
@ -111,7 +112,7 @@ def test_pihole_user_group_creation(Pihole):
expected_stdout = tick_box + ' Checking for user \'pihole\'' expected_stdout = tick_box + ' Checking for user \'pihole\''
assert expected_stdout in user_create.stdout assert expected_stdout in user_create.stdout
# situation where only group and no user exists # situation where only group and no user exists
Pihole.run('su --shell /bin/bash --command "userdel -r pihole" -p root') Pihole.run(sudo_cmd.format('userdel -r pihole'))
user_create = Pihole.run(''' user_create = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
create_pihole_user create_pihole_user
@ -119,10 +120,13 @@ def test_pihole_user_group_creation(Pihole):
expected_stdout = tick_box + ' Creating user \'pihole\'' expected_stdout = tick_box + ' Creating user \'pihole\''
assert expected_stdout in user_create.stdout assert expected_stdout in user_create.stdout
# situation where only user and no group exists # situation where only user and no group exists
Pihole.run('su --shell /bin/bash --command "userdel -r pihole" -p root') Pihole.run(sudo_cmd.format('userdel -r pihole'))
Pihole.run('su --shell /bin/bash --command "groupdel pihole" -p root') Pihole.run(sudo_cmd.format('groupdel pihole'))
Pihole.run('su --shell /bin/bash --command "groupadd pihole_dummy" -p root') Pihole.run(sudo_cmd.format('groupadd pihole_dummy'))
Pihole.run('su --shell /bin/bash --command "useradd -r --no-user-group -g pihole_dummy -s /usr/sbin/nologin pihole" -p root') useradd_dummy = (
'useradd -r --no-user-group -g pihole_dummy ' +
'-s /usr/sbin/nologin pihole')
Pihole.run(sudo_cmd.format(useradd_dummy))
user_create = Pihole.run(''' user_create = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
create_pihole_user create_pihole_user