diff --git a/pyinfra/api/connectors/util.py b/pyinfra/api/connectors/util.py index a8266d6b9..0f98425bd 100644 --- a/pyinfra/api/connectors/util.py +++ b/pyinfra/api/connectors/util.py @@ -266,7 +266,7 @@ def make_unix_command( _warn_invalid_auth_args( locals(), 'doas', - ('doas_user'), + ('doas_user',), ) if use_sudo_password: diff --git a/tests/test_connectors/test_util.py b/tests/test_connectors/test_util.py index d89354bb6..bc40b0a70 100644 --- a/tests/test_connectors/test_util.py +++ b/tests/test_connectors/test_util.py @@ -131,8 +131,20 @@ def test_command_exists_su_config_only(self): class TestMakeUnixCommandConnectorUtilWarnings(TestCase): + def test_doas_warnings(self): + state = State(make_inventory(), Config(SU_USER=True, SUDO=True)) + + with patch('pyinfra.api.connectors.util._warn_invalid_auth_args') as fake_auth_args: + command = make_unix_command('echo Šablony', state=state) + + assert command.get_raw_value() == "sh -c 'echo Šablony'" + fake_auth_args.assert_called_once() + _, args, kwargs = fake_auth_args.mock_calls[0] + assert args[1] == 'doas' + assert args[2] == ('doas_user',) + def test_sudo_warnings(self): - state = State(make_inventory(), Config(SU_USER=True)) + state = State(make_inventory(), Config(SU_USER=True, DOAS=True)) with patch('pyinfra.api.connectors.util._warn_invalid_auth_args') as fake_auth_args: command = make_unix_command('echo Šablony', state=state) @@ -144,7 +156,7 @@ def test_sudo_warnings(self): assert args[2] == ('use_sudo_password', 'use_sudo_login', 'preserve_sudo_env', 'sudo_user') def test_su_warnings(self): - state = State(make_inventory(), Config(SUDO=True)) + state = State(make_inventory(), Config(DOAS=True, SUDO=True)) with patch('pyinfra.api.connectors.util._warn_invalid_auth_args') as fake_auth_args: command = make_unix_command('echo Šablony', state=state)