|
@@ -1877,7 +1877,8 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
|
|
|
name='appvm', qid=3)
|
|
|
vm.netvm = None
|
|
|
vm.guivm = guivm
|
|
|
- guivm.features['keyboard-layout'] = 'fr++'
|
|
|
+ vm.is_running = lambda: True
|
|
|
+ guivm.keyboard_layout = 'fr++'
|
|
|
guivm.is_running = lambda: True
|
|
|
vm.events_enabled = True
|
|
|
test_qubesdb = TestQubesDB()
|
|
@@ -1925,6 +1926,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
|
|
|
name='appvm', qid=3)
|
|
|
vm.netvm = None
|
|
|
vm.audiovm = audiovm
|
|
|
+ vm.is_running = lambda: True
|
|
|
audiovm.is_running = lambda: True
|
|
|
vm.events_enabled = True
|
|
|
test_qubesdb = TestQubesDB()
|
|
@@ -1968,8 +1970,87 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
|
|
|
name='sys-gui', qid=2, provides_network=False)
|
|
|
guivm.is_running = lambda: True
|
|
|
guivm.events_enabled = True
|
|
|
- with self.assertRaises(qubes.exc.QubesValueError):
|
|
|
- guivm.features['keyboard-layout'] = 'fr123++'
|
|
|
+ with self.assertRaises(qubes.exc.QubesPropertyValueError):
|
|
|
+ guivm.keyboard_layout = 'fr123++'
|
|
|
+
|
|
|
+ with self.assertRaises(qubes.exc.QubesPropertyValueError):
|
|
|
+ guivm.keyboard_layout = 'fr+???+'
|
|
|
+
|
|
|
+ with self.assertRaises(qubes.exc.QubesPropertyValueError):
|
|
|
+ guivm.keyboard_layout = 'fr++variant?'
|
|
|
+
|
|
|
+ with self.assertRaises(qubes.exc.QubesPropertyValueError):
|
|
|
+ guivm.keyboard_layout = 'fr'
|
|
|
+
|
|
|
+ @unittest.mock.patch('qubes.utils.get_timezone')
|
|
|
+ @unittest.mock.patch('qubes.utils.urandom')
|
|
|
+ @unittest.mock.patch('qubes.vm.qubesvm.QubesVM.untrusted_qdb')
|
|
|
+ def test_625_qdb_keyboard_layout_change(self, mock_qubesdb, mock_urandom,
|
|
|
+ mock_timezone):
|
|
|
+ mock_urandom.return_value = b'A' * 64
|
|
|
+ mock_timezone.return_value = 'UTC'
|
|
|
+ template = self.get_vm(
|
|
|
+ cls=qubes.vm.templatevm.TemplateVM, name='template')
|
|
|
+ template.netvm = None
|
|
|
+ guivm = self.get_vm(cls=qubes.vm.appvm.AppVM, template=template,
|
|
|
+ name='sys-gui', qid=2, provides_network=False)
|
|
|
+ vm = self.get_vm(cls=qubes.vm.appvm.AppVM, template=template,
|
|
|
+ name='appvm', qid=3)
|
|
|
+ vm.netvm = None
|
|
|
+ vm.guivm = guivm
|
|
|
+ vm.is_running = lambda: True
|
|
|
+ guivm.keyboard_layout = 'fr++'
|
|
|
+ guivm.is_running = lambda: True
|
|
|
+ vm.events_enabled = True
|
|
|
+ test_qubesdb = TestQubesDB()
|
|
|
+ mock_qubesdb.write.side_effect = test_qubesdb.write
|
|
|
+ mock_qubesdb.rm.side_effect = test_qubesdb.rm
|
|
|
+ vm.create_qdb_entries()
|
|
|
+ self.maxDiff = None
|
|
|
+
|
|
|
+ expected = {
|
|
|
+ '/name': 'test-inst-appvm',
|
|
|
+ '/type': 'AppVM',
|
|
|
+ '/default-user': 'user',
|
|
|
+ '/keyboard-layout': 'fr++',
|
|
|
+ '/qubes-vm-type': 'AppVM',
|
|
|
+ '/qubes-gui-domain-xid': '{}'.format(guivm.xid),
|
|
|
+ '/qubes-debug-mode': '0',
|
|
|
+ '/qubes-base-template': 'test-inst-template',
|
|
|
+ '/qubes-timezone': 'UTC',
|
|
|
+ '/qubes-random-seed': base64.b64encode(b'A' * 64),
|
|
|
+ '/qubes-vm-persistence': 'rw-only',
|
|
|
+ '/qubes-vm-updateable': 'False',
|
|
|
+ '/qubes-block-devices': '',
|
|
|
+ '/qubes-usb-devices': '',
|
|
|
+ '/qubes-iptables': 'reload',
|
|
|
+ '/qubes-iptables-error': '',
|
|
|
+ '/qubes-iptables-header': unittest.mock.ANY,
|
|
|
+ '/qubes-service/qubes-update-check': '0',
|
|
|
+ '/qubes-service/meminfo-writer': '1',
|
|
|
+ '/connected-ips': '',
|
|
|
+ '/connected-ips6': '',
|
|
|
+ }
|
|
|
+
|
|
|
+ with self.subTest('default'):
|
|
|
+ self.assertEqual(test_qubesdb.data, expected)
|
|
|
+
|
|
|
+ with self.subTest('value_change'):
|
|
|
+ vm.keyboard_layout = 'de++'
|
|
|
+ expected['/keyboard-layout'] = 'de++'
|
|
|
+ self.assertEqual(test_qubesdb.data, expected)
|
|
|
+
|
|
|
+ with self.subTest('value_revert'):
|
|
|
+ vm.keyboard_layout = qubes.property.DEFAULT
|
|
|
+ expected['/keyboard-layout'] = 'fr++'
|
|
|
+ self.assertEqual(test_qubesdb.data, expected)
|
|
|
+
|
|
|
+ with self.subTest('no_default'):
|
|
|
+ guivm.keyboard_layout = qubes.property.DEFAULT
|
|
|
+ vm.keyboard_layout = qubes.property.DEFAULT
|
|
|
+ expected['/keyboard-layout'] = 'us++'
|
|
|
+ self.assertEqual(test_qubesdb.data, expected)
|
|
|
+
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
def coroutine_mock(self, mock, *args, **kwargs):
|