From cbc7241a93828d0aceee073d20eece35aa3018ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 17 Jul 2017 02:41:42 +0200 Subject: [PATCH] api/admin: rename mgmt-permission:* event to admin-permission:* Be more consistent with Admin API name and method names. --- qubes/api/__init__.py | 4 ++-- qubes/api/admin.py | 2 +- qubes/ext/admin.py | 4 ++-- qubes/tests/api_admin.py | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/qubes/api/__init__.py b/qubes/api/__init__.py index 2783e486..38532913 100644 --- a/qubes/api/__init__.py +++ b/qubes/api/__init__.py @@ -91,7 +91,7 @@ def method(name, *, no_payload=False, endpoints=None, **classifiers): def apply_filters(iterable, filters): - '''Apply filters returned by mgmt-permission:... event''' + '''Apply filters returned by admin-permission:... event''' for selector in filters: iterable = filter(selector, iterable) return iterable @@ -188,7 +188,7 @@ class AbstractQubesAPI(object): def fire_event_for_permission(self, **kwargs): '''Fire an event on the source qube to check for permission''' - return self.src.fire_event('mgmt-permission:' + self.method, + return self.src.fire_event('admin-permission:' + self.method, pre_event=True, dest=self.dest, arg=self.arg, **kwargs) def fire_event_for_filter(self, iterable, **kwargs): diff --git a/qubes/api/admin.py b/qubes/api/admin.py index aa1a2958..674c8f76 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -43,7 +43,7 @@ class QubesMgmtEventsDispatcher(object): self.send_event = send_event def vm_handler(self, subject, event, **kwargs): - if event.startswith('mgmt-permission:'): + if event.startswith('admin-permission:'): return if not list(qubes.api.apply_filters([(subject, event, kwargs)], self.filters)): diff --git a/qubes/ext/admin.py b/qubes/ext/admin.py index 30feef7b..1c43d3ac 100644 --- a/qubes/ext/admin.py +++ b/qubes/ext/admin.py @@ -23,8 +23,8 @@ import qubes.ext class AdminExtension(qubes.ext.Extension): # pylint: disable=too-few-public-methods @qubes.ext.handler( - 'mgmt-permission:admin.vm.tag.Set', - 'mgmt-permission:admin.vm.tag.Remove') + 'admin-permission:admin.vm.tag.Set', + 'admin-permission:admin.vm.tag.Remove') def on_tag_set_or_remove(self, vm, event, arg, **kwargs): '''Forbid changing specific tags''' # pylint: disable=no-self-use,unused-argument diff --git a/qubes/tests/api_admin.py b/qubes/tests/api_admin.py index 251e65d3..1e05692d 100644 --- a/qubes/tests/api_admin.py +++ b/qubes/tests/api_admin.py @@ -91,7 +91,7 @@ class AdminAPITestCase(qubes.tests.QubesTestCase): response = loop.run_until_complete( mgmt_obj.execute(untrusted_payload=payload)) self.assertEventFired(self.emitter, - 'mgmt-permission:' + method.decode('ascii')) + 'admin-permission:' + method.decode('ascii')) return response @@ -110,7 +110,7 @@ class TC_00_VMs(AdminAPITestCase): def test_010_vm_property_list(self): # this test is kind of stupid, but at least check if appropriate - # mgmt-permission event is fired + # admin-permission event is fired value = self.call_mgmt_func(b'admin.vm.property.List', b'test-vm1') properties = self.app.domains['test-vm1'].property_list() self.assertEqual(value, @@ -902,7 +902,7 @@ class TC_00_VMs(AdminAPITestCase): loop.run_until_complete(execute_task) self.assertIsNone(execute_task.result()) self.assertEventFired(self.emitter, - 'mgmt-permission:' + 'admin.Events') + 'admin-permission:' + 'admin.Events') self.assertEqual(send_event.mock_calls, [ unittest.mock.call(self.app, 'connection-established'), @@ -932,7 +932,7 @@ class TC_00_VMs(AdminAPITestCase): vm2 = event_task.result() self.assertIsNone(execute_task.result()) self.assertEventFired(self.emitter, - 'mgmt-permission:' + 'admin.Events') + 'admin-permission:' + 'admin.Events') self.assertEqual(send_event.mock_calls, [ unittest.mock.call(self.app, 'connection-established'), @@ -1242,7 +1242,7 @@ class TC_00_VMs(AdminAPITestCase): def test_400_property_list(self): # actual function tested for admin.vm.property.* already # this test is kind of stupid, but at least check if appropriate - # mgmt-permission event is fired + # admin-permission event is fired value = self.call_mgmt_func(b'admin.property.List', b'dom0') properties = self.app.property_list() self.assertEqual(value,