Skip to content

Commit

Permalink
Fix apply in Updates tab in Global Config
Browse files Browse the repository at this point in the history
Also add test for it.

fixes QubesOS/qubes-issues#8132
  • Loading branch information
marmarta committed May 1, 2023
1 parent 6857dbe commit 8420fb9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
9 changes: 6 additions & 3 deletions qubes_config/global_config/updates_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,8 @@ def __init__(self, gtk_builder: Gtk.Builder, qapp: qubesadmin.Qubes,
self.whonix_updatevm_box: Gtk.Box = \
gtk_builder.get_object('updates_whonix_updatevm_box')

self.rules, self.current_token = \
self.policy_manager.get_rules_from_filename(
self.policy_file_name, "")
self.rules: List[Rule] = []
self.current_token: Optional[str] = None

self.exception_list_handler = PolicyExceptionsHandler(
gtk_builder=gtk_builder, prefix='updates_updatevm',
Expand Down Expand Up @@ -439,8 +438,12 @@ def _needs_updatevm_filter(vm):

def load_rules(self):
"""Load rules into widgets."""
self.rules, self.current_token = \
self.policy_manager.get_rules_from_filename(
self.policy_file_name, "")
def_updatevm = self.default_updatevm
def_whonix_updatevm = None

if self.has_whonix:
def_whonix_updatevm = self.default_whonix_updatevm

Expand Down
24 changes: 24 additions & 0 deletions qubes_config/tests/test_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,30 @@ def test_update_proxy_save_updatevm(mock_feature, real_builder,
'service.qubes-updates-proxy', None) in \
mock_feature.mock_calls

@patch('qubes_config.global_config.updates_handler.apply_feature_change')
def test_update_proxy_apply(mock_feature, real_builder,
test_qapp_whonix, test_policy_manager):
# pylint: disable=unused-argument
handler = UpdateProxy(real_builder, test_qapp_whonix, test_policy_manager,
'proxy-file', 'Proxy')

assert handler.has_whonix
assert handler.updatevm_model.get_selected() == 'sys-net'
assert handler.whonix_updatevm_model.get_selected() == 'sys-whonix'

assert handler.updatevm_model.is_vm_available('sys-firewall')
assert handler.whonix_updatevm_model.is_vm_available('anon-whonix')

handler.updatevm_model.select_value('sys-firewall')
handler.whonix_updatevm_model.select_value('anon-whonix')

handler.save()

handler.reset()

assert str(handler.updatevm_model.get_selected()) == 'sys-firewall'
assert str(handler.whonix_updatevm_model.get_selected()) == 'anon-whonix'


@patch('qubes_config.global_config.updates_handler.apply_feature_change')
def test_update_proxy_save_justwhonix(mock_feature, real_builder,
Expand Down

0 comments on commit 8420fb9

Please sign in to comment.