Merge ~cgrabowski/maas:add_filter_groups_and_options_to_allowed_methods into maas:master

Proposed by Christian Grabowski
Status: Merged
Approved by: Christian Grabowski
Approved revision: 544e6b12e6e8ea2dc2370451138d6c18123e9d67
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:add_filter_groups_and_options_to_allowed_methods
Merge into: maas:master
Diff against target: 93 lines (+64/-0)
2 files modified
src/maasserver/websockets/handlers/machine.py (+2/-0)
src/maasserver/websockets/handlers/tests/test_machine.py (+62/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alexsander de Souza Approve
Review via email: mp+425324@code.launchpad.net

Commit message

add filter groups and options to allowed_methods on Machine handler

To post a comment you must log in.
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

+1

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

I wonder if it's worth adding a test that lists the methods that are available but not allowed, so anyone adding a new method will see a failure and have to decide to either allow it or adjust the test to approve disallowing it

Revision history for this message
Christian Grabowski (cgrabowski) wrote :

> I wonder if it's worth adding a test that lists the methods that are available
> but not allowed, so anyone adding a new method will see a failure and have to
> decide to either allow it or adjust the test to approve disallowing it

I think that's a good idea, will add.

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b add_filter_groups_and_options_to_allowed_methods lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 1549fd527add2f3cade9763622964695f78c8118

review: Approve
544e6b1... by Christian Grabowski

add test for allowed_methods on Machine handler

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b add_filter_groups_and_options_to_allowed_methods lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 544e6b12e6e8ea2dc2370451138d6c18123e9d67

review: Approve

Update scan failed

At least one of the branches involved have failed to scan. You can manually schedule a rescan if required.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
index 262f7f9..495a43c 100644
--- a/src/maasserver/websockets/handlers/machine.py
+++ b/src/maasserver/websockets/handlers/machine.py
@@ -199,6 +199,8 @@ class MachineHandler(NodeHandler):
199 "get_latest_failed_testing_script_results",199 "get_latest_failed_testing_script_results",
200 "get_workload_annotations",200 "get_workload_annotations",
201 "set_workload_annotations",201 "set_workload_annotations",
202 "filter_groups",
203 "filter_options",
202 ]204 ]
203 form = AdminMachineWithMACAddressesForm205 form = AdminMachineWithMACAddressesForm
204 exclude = [206 exclude = [
diff --git a/src/maasserver/websockets/handlers/tests/test_machine.py b/src/maasserver/websockets/handlers/tests/test_machine.py
index 0dd40ea..93835ef 100644
--- a/src/maasserver/websockets/handlers/tests/test_machine.py
+++ b/src/maasserver/websockets/handlers/tests/test_machine.py
@@ -9,6 +9,7 @@ import logging
9from operator import itemgetter9from operator import itemgetter
10import random10import random
11import re11import re
12from types import FunctionType
12from unittest.mock import ANY13from unittest.mock import ANY
1314
14from django.core.exceptions import ValidationError15from django.core.exceptions import ValidationError
@@ -547,6 +548,67 @@ class TestMachineHandler(MAASServerTestCase):
547 node_type=NODE_TYPE.DEVICE, parent=node, interface=True548 node_type=NODE_TYPE.DEVICE, parent=node, interface=True
548 )549 )
549550
551 def test_allowed_methods(self):
552 not_allowed_methods = [
553 "dehydrate",
554 "dehydrate_all_ip_addresses",
555 "dehydrate_blockdevice",
556 "dehydrate_cache_set",
557 "dehydrate_created",
558 "dehydrate_device",
559 "dehydrate_domain",
560 "dehydrate_events",
561 "dehydrate_filesystem",
562 "dehydrate_hugepages",
563 "dehydrate_interface",
564 "dehydrate_ip_address",
565 "dehydrate_last_image_sync",
566 "dehydrate_numanode",
567 "dehydrate_owner",
568 "dehydrate_partitions",
569 "dehydrate_pod",
570 "dehydrate_pool",
571 "dehydrate_power_parameters",
572 "dehydrate_script_set_status",
573 "dehydrate_show_os_info",
574 "dehydrate_test_statuses",
575 "dehydrate_updated",
576 "dehydrate_vlan",
577 "dehydrate_volume_group",
578 "dehydrate_zone",
579 "delete",
580 "execute",
581 "full_dehydrate",
582 "full_hydrate",
583 "get_all_fabric_names",
584 "get_all_space_names",
585 "get_all_storage_tags",
586 "get_all_subnets",
587 "get_blockdevices_for",
588 "get_form_class",
589 "get_grouped_storages",
590 "get_mac_addresses",
591 "get_object",
592 "get_providing_dhcp",
593 "get_queryset",
594 "hydrate",
595 "listen",
596 "on_listen",
597 "on_listen_for_active_pk",
598 "preprocess_form",
599 "preprocess_node_form",
600 "refetch",
601 "update_blockdevice_filesystem",
602 "update_partition_filesystem",
603 ]
604 [
605 self.assertIn(attr, MachineHandler.Meta.allowed_methods)
606 for attr in dir(MachineHandler)
607 if isinstance(getattr(MachineHandler, attr), FunctionType)
608 and attr not in not_allowed_methods
609 and not attr.startswith("_")
610 ]
611
550 def test_get_refresh_script_result_cache(self):612 def test_get_refresh_script_result_cache(self):
551 owner = factory.make_User()613 owner = factory.make_User()
552 node = factory.make_Node(owner=owner)614 node = factory.make_Node(owner=owner)

Subscribers

People subscribed via source and target branches