tests: add a function for adding qrexec rules

QubesOS/qubes-issues#1800
This commit is contained in:
Marek Marczykowski-Górecki 2016-03-03 01:07:23 +01:00
parent 29c602c9ff
commit 3f66da0412
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 25 additions and 0 deletions

View File

@ -424,6 +424,30 @@ class SystemTestsMixin(object):
for vmname in vmnames:
cls._remove_vm_disk(vmname)
def qrexec_policy(self, service, source, destination, allow=True):
"""
Allow qrexec calls for duration of the test
:param service: service name
:param source: source VM name
:param destination: destination VM name
:return:
"""
def add_remove_rule(add=True):
with open('/etc/qubes-rpc/policy/{}'.format(service), 'r+') as policy:
policy_rules = policy.readlines()
rule = "{} {} {}\n".format(source, destination,
'allow' if allow else 'deny')
if add:
policy_rules.insert(0, rule)
else:
policy_rules.remove(rule)
policy.truncate(0)
policy.seek(0)
policy.write(''.join(policy_rules))
add_remove_rule(add=True)
self.addCleanup(add_remove_rule, add=False)
def wait_for_window(self, title, timeout=30, show=True):
"""
Wait for a window with a given title. Depending on show parameter,

1
tests/extra.py Normal file
View File

@ -0,0 +1 @@
__author__ = 'user'