From 0968c25486bd20612aee7f657e816a16df77eee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 2 Aug 2016 02:15:08 +0200 Subject: [PATCH] tests: when creating AppVM based on whonix-ws, connect it to tor Use sys-whonix if exists. This makes network-related tests more realistic. --- tests/extra.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/extra.py b/tests/extra.py index c46a8a81..d818c503 100644 --- a/tests/extra.py +++ b/tests/extra.py @@ -34,6 +34,7 @@ class ExtraTestCase(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase): def setUp(self): super(ExtraTestCase, self).setUp() self.qc.unlock_db() + self.default_netvm = None def create_vms(self, names): """ @@ -52,7 +53,9 @@ class ExtraTestCase(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase): for vmname in names: vm = self.qc.add_new_vm("QubesAppVm", name=self.make_vm_name(vmname), - template=template) + template=template, + uses_default_netvm=False, + netvm=self.default_netvm) vm.create_on_disk(verbose=False) self.save_and_reload_db() self.qc.unlock_db() @@ -67,9 +70,11 @@ class ExtraTestCase(qubes.tests.SystemTestsMixin, qubes.tests.QubesTestCase): """ Enable access to the network. Must be called before creating VMs. """ - # nothing to do in core2 - pass - + self.default_netvm = self.qc.get_default_netvm() + if self.template.startswith('whonix-ws'): + whonix_netvm = self.qc.get_vm_by_name('sys-whonix') + if whonix_netvm: + self.default_netvm = whonix_netvm def load_tests(loader, tests, pattern): for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):