Skip to content

Commit

Permalink
Fixed grey label color value causing accidental green icons
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarta committed Aug 13, 2020
1 parent 66d8a78 commit 20fe4bf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 6 additions & 1 deletion qubes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ def _migrate_global_properties(self):
pass
node_default_fw_netvm.getparent().remove(node_default_fw_netvm)

# fix grey being green
grey_label = self.xml.find('./labels/label[@color=\'0x555753\']')
if grey_label:
grey_label.set('color', '0x555555')

def load(self, lock=False):
"""Open qubes.xml
Expand Down Expand Up @@ -1211,7 +1216,7 @@ def load_initial_values(self):
2: qubes.Label(2, '0xf57900', 'orange'),
3: qubes.Label(3, '0xedd400', 'yellow'),
4: qubes.Label(4, '0x73d216', 'green'),
5: qubes.Label(5, '0x555753', 'gray'),
5: qubes.Label(5, '0x555555', 'gray'),
6: qubes.Label(6, '0x3465a4', 'blue'),
7: qubes.Label(7, '0x75507b', 'purple'),
8: qubes.Label(8, '0x000000', 'black'),
Expand Down
43 changes: 43 additions & 0 deletions qubes/tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,49 @@ def test_100_property_migrate_default_fw_netvm(self):
self.app.close()
del self.app

def test_101_property_migrate_label(self):
xml_template = """<?xml version="1.0" encoding="utf-8" ?>
<qubes version="3.0">
<labels>
<label id="label-1" color="{old_gray}">gray</label>
</labels>
<pools>
<pool driver="file" dir_path="/tmp/qubes-test" name="default"/>
</pools>
<domains>
<domain class="StandaloneVM" id="domain-1">
<properties>
<property name="qid">1</property>
<property name="name">sys-net</property>
<property name="provides_network">True</property>
<property name="label" ref="label-1" />
<property name="netvm"></property>
<property name="uuid">2fcfc1f4-b2fe-4361-931a-c5294b35edfa</property>
</properties>
<features/>
<devices class="pci"/>
</domain>
</domains>
</qubes>
"""
with self.subTest('replace_label'):
with open('/tmp/qubestest.xml', 'w') as xml_file:
xml_file.write(xml_template.format(old_gray='0x555753'))
self.app = qubes.Qubes('/tmp/qubestest.xml', offline_mode=True)
self.assertEqual(
self.app.get_label('gray').color, '0x555555')
self.app.close()
del self.app

with self.subTest('dont_replace_label'):
with open('/tmp/qubestest.xml', 'w') as xml_file:
xml_file.write(xml_template.format(old_gray='0x123456'))
self.app = qubes.Qubes('/tmp/qubestest.xml', offline_mode=True)
self.assertEqual(
self.app.get_label('gray').color, '0x123456')
self.app.close()
del self.app


class TC_90_Qubes(qubes.tests.QubesTestCase):
def tearDown(self):
Expand Down

0 comments on commit 20fe4bf

Please sign in to comment.