@@ -131,8 +131,20 @@ def test_command_exists_su_config_only(self):
131
131
132
132
133
133
class TestMakeUnixCommandConnectorUtilWarnings (TestCase ):
134
+ def test_doas_warnings (self ):
135
+ state = State (make_inventory (), Config (SU_USER = True , SUDO = True ))
136
+
137
+ with patch ('pyinfra.api.connectors.util._warn_invalid_auth_args' ) as fake_auth_args :
138
+ command = make_unix_command ('echo Šablony' , state = state )
139
+
140
+ assert command .get_raw_value () == "sh -c 'echo Šablony'"
141
+ fake_auth_args .assert_called_once ()
142
+ _ , args , kwargs = fake_auth_args .mock_calls [0 ]
143
+ assert args [1 ] == 'doas'
144
+ assert args [2 ] == ('doas_user' ,)
145
+
134
146
def test_sudo_warnings (self ):
135
- state = State (make_inventory (), Config (SU_USER = True ))
147
+ state = State (make_inventory (), Config (SU_USER = True , DOAS = True ))
136
148
137
149
with patch ('pyinfra.api.connectors.util._warn_invalid_auth_args' ) as fake_auth_args :
138
150
command = make_unix_command ('echo Šablony' , state = state )
@@ -144,7 +156,7 @@ def test_sudo_warnings(self):
144
156
assert args [2 ] == ('use_sudo_password' , 'use_sudo_login' , 'preserve_sudo_env' , 'sudo_user' )
145
157
146
158
def test_su_warnings (self ):
147
- state = State (make_inventory (), Config (SUDO = True ))
159
+ state = State (make_inventory (), Config (DOAS = True , SUDO = True ))
148
160
149
161
with patch ('pyinfra.api.connectors.util._warn_invalid_auth_args' ) as fake_auth_args :
150
162
command = make_unix_command ('echo Šablony' , state = state )
0 commit comments