Merge lp:~blake-rouse/maas/fix-1592132 into lp:maas/trunk

Proposed by Blake Rouse on 2016-06-14
Status: Merged
Approved by: Blake Rouse on 2016-06-15
Approved revision: 5116
Merged at revision: 5123
Proposed branch: lp:~blake-rouse/maas/fix-1592132
Merge into: lp:maas/trunk
Diff against target: 104 lines (+43/-1)
3 files modified
src/maasserver/api/domains.py (+8/-0)
src/maasserver/api/tests/test_enlistment.py (+19/-0)
src/maasserver/api/zones.py (+16/-1)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1592132
Reviewer Review Type Date Requested Status
Andres Rodriguez 2016-06-14 Approve on 2016-06-15
Review via email: mp+297381@code.launchpad.net

Commit message

Fix anonymous machines create endpoint to return the correct fields on domain and zone.

To post a comment you must log in.
Andres Rodriguez (andreserl) wrote :

It looks good to me...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/domains.py'
2--- src/maasserver/api/domains.py 2016-04-28 10:13:46 +0000
3+++ src/maasserver/api/domains.py 2016-06-14 18:38:54 +0000
4@@ -5,6 +5,7 @@
5
6 from maasserver.api.support import (
7 admin_method,
8+ AnonymousOperationsHandler,
9 operation,
10 OperationsHandler,
11 )
12@@ -78,6 +79,13 @@
13 dns_force_reload()
14
15
16+class AnonDomainHandler(AnonymousOperationsHandler):
17+ """Anonymous access to domain."""
18+ read = create = update = delete = None
19+ model = Domain
20+ fields = DISPLAYED_DOMAIN_FIELDS
21+
22+
23 class DomainHandler(OperationsHandler):
24 """Manage domain."""
25 api_doc_section_name = "Domain"
26
27=== modified file 'src/maasserver/api/tests/test_enlistment.py'
28--- src/maasserver/api/tests/test_enlistment.py 2016-06-10 02:57:23 +0000
29+++ src/maasserver/api/tests/test_enlistment.py 2016-06-14 18:38:54 +0000
30@@ -377,6 +377,7 @@
31 'mac_addresses': ['aa:bb:cc:dd:ee:ff', '22:bb:cc:dd:ee:ff'],
32 })
33 parsed_result = json_load_bytes(response.content)
34+ # Limited fields on machine.
35 self.assertItemsEqual(
36 [
37 'system_id',
38@@ -395,6 +396,24 @@
39 'resource_uri',
40 ],
41 list(parsed_result))
42+ # Limited fields on domain.
43+ self.assertItemsEqual(
44+ [
45+ 'id',
46+ 'name',
47+ 'ttl',
48+ 'authoritative',
49+ 'resource_record_count',
50+ ],
51+ list(parsed_result['domain']))
52+ # Limited fields on zone.
53+ self.assertItemsEqual(
54+ [
55+ 'id',
56+ 'name',
57+ 'description',
58+ ],
59+ list(parsed_result['zone']))
60
61
62 class SimpleUserLoggedInEnlistmentAPITest(APITestCase.ForUser):
63
64=== modified file 'src/maasserver/api/zones.py'
65--- src/maasserver/api/zones.py 2016-03-28 13:54:47 +0000
66+++ src/maasserver/api/zones.py 2016-06-14 18:38:54 +0000
67@@ -11,6 +11,7 @@
68 from django.shortcuts import get_object_or_404
69 from maasserver.api.support import (
70 admin_method,
71+ AnonymousOperationsHandler,
72 OperationsHandler,
73 )
74 from maasserver.exceptions import MAASAPIValidationError
75@@ -20,6 +21,20 @@
76 from piston3.utils import rc
77
78
79+DISPLAYED_ZONE_FIELDS = (
80+ 'id',
81+ 'name',
82+ 'description',
83+)
84+
85+
86+class AnonZoneHandler(AnonymousOperationsHandler):
87+ """Anonymous access to zone."""
88+ read = create = update = delete = None
89+ model = Zone
90+ fields = DISPLAYED_ZONE_FIELDS
91+
92+
93 class ZoneHandler(OperationsHandler):
94 """Manage a physical zone.
95
96@@ -33,7 +48,7 @@
97 """
98 api_doc_section_name = "Zone"
99 model = Zone
100- fields = ('name', 'description')
101+ fields = DISPLAYED_ZONE_FIELDS
102
103 # Creation happens on the ZonesHandler.
104 create = None