tests: add test for guivm and keyboard_layout
This commit is contained in:
parent
5ee2f5d889
commit
e667639914
@ -1469,6 +1469,71 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
|
||||
netvm.create_qdb_entries()
|
||||
self.assertEqual(test_qubesdb.data, expected)
|
||||
|
||||
@unittest.mock.patch('qubes.utils.get_timezone')
|
||||
@unittest.mock.patch('qubes.utils.urandom')
|
||||
@unittest.mock.patch('qubes.vm.qubesvm.QubesVM.untrusted_qdb')
|
||||
def test_622_qdb_keyboard_layout(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
|
||||
guivm.features['keyboard-layout'] = 'fr'
|
||||
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
|
||||
|
||||
iptables_header = (
|
||||
'# Generated by Qubes Core on {}\n'
|
||||
'*filter\n'
|
||||
':INPUT DROP [0:0]\n'
|
||||
':FORWARD DROP [0:0]\n'
|
||||
':OUTPUT ACCEPT [0:0]\n'
|
||||
'-A INPUT -i vif+ -p udp -m udp --dport 68 -j DROP\n'
|
||||
'-A INPUT -m conntrack --ctstate '
|
||||
'RELATED,ESTABLISHED -j ACCEPT\n'
|
||||
'-A INPUT -p icmp -j ACCEPT\n'
|
||||
'-A INPUT -i lo -j ACCEPT\n'
|
||||
'-A INPUT -j REJECT --reject-with '
|
||||
'icmp-host-prohibited\n'
|
||||
'-A FORWARD -m conntrack --ctstate '
|
||||
'RELATED,ESTABLISHED -j ACCEPT\n'
|
||||
'-A FORWARD -i vif+ -o vif+ -j DROP\n'
|
||||
'COMMIT\n'.format(datetime.datetime.now().ctime()))
|
||||
|
||||
self.assertEqual(test_qubesdb.data, {
|
||||
'/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': iptables_header,
|
||||
'/qubes-service/qubes-update-check': '0',
|
||||
'/qubes-service/meminfo-writer': '1',
|
||||
})
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def coroutine_mock(self, mock, *args, **kwargs):
|
||||
return mock(*args, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user