qubespolicy: fix handling ask,default_target=
This commit is contained in:
parent
502f753be9
commit
d650a90289
@ -378,7 +378,6 @@ class PolicyAction(object):
|
||||
:return: None
|
||||
'''
|
||||
assert self.action == Action.ask
|
||||
assert self.target is None
|
||||
if response:
|
||||
assert target in self.targets_for_ask
|
||||
self.target = target
|
||||
|
@ -444,6 +444,15 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase):
|
||||
action.handle_user_response(False, None)
|
||||
self.assertEqual(action.action, qubespolicy.Action.deny)
|
||||
|
||||
def test_013_handle_user_response_with_default_target(self):
|
||||
rule = qubespolicy.PolicyRule(
|
||||
'$anyvm $anyvm ask,default_target=test-vm2')
|
||||
action = qubespolicy.PolicyAction('test.service', 'test-vm1',
|
||||
None, rule, 'test-vm2', ['test-vm2', 'test-vm3'])
|
||||
action.handle_user_response(True, 'test-vm2')
|
||||
self.assertEqual(action.action, qubespolicy.Action.allow)
|
||||
self.assertEqual(action.target, 'test-vm2')
|
||||
|
||||
@unittest.mock.patch('qubespolicy.qubesd_call')
|
||||
@unittest.mock.patch('subprocess.call')
|
||||
def test_020_execute(self, mock_subprocess, mock_qubesd_call):
|
||||
|
Loading…
Reference in New Issue
Block a user