features: fix serialization
qubesd_call expect "bytes" type. Additionally serialize false value as empty string (which is treated by python as false value), because otherwise would be serialized to (non-empty) string, which is true value in python.
This commit is contained in:
parent
3217d8af6f
commit
ee81902979
@ -42,7 +42,12 @@ class Features(object):
|
||||
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Remove', key)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key, value)
|
||||
if not value:
|
||||
# False value needs to be serialized as empty string
|
||||
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key, b'')
|
||||
else:
|
||||
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key,
|
||||
str(value).encode())
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.vm.qubesd_call(
|
||||
|
@ -51,7 +51,7 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase):
|
||||
b'0\x00some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.feature.Set',
|
||||
'feature3', 'value of feature')] = b'0\x00'
|
||||
'feature3', b'value of feature')] = b'0\x00'
|
||||
self.assertEqual(
|
||||
qubesadmin.tools.qvm_features.main(['some-vm', 'feature3',
|
||||
'value of feature'],
|
||||
|
Loading…
Reference in New Issue
Block a user