~weii666/ubuntu/trusty/maas/fix-for-1325167

« back to all changes in this revision

Viewing changes to src/maasserver/views/tests/test_settings.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Andres Rodriguez, Jason Hobbs, Jeroen Vermeulen
  • Date: 2014-04-03 13:45:02 UTC
  • mfrom: (1.2.27)
  • Revision ID: package-import@ubuntu.com-20140403134502-k8ocidn51k203zzw
Tags: 1.5+bzr2227-0ubuntu1
* New upstream bugfix release:
  - Fix catching exceptions raised by
    twisted.conch.ssh.keys.Key.fromString (LP: #1298788)
  - Fix validationg in default NodeGroupInterface.broadcast_ip making it
    optional. (LP: #1299374)
  - Drop install-pxe-bootloader as it conflicts with newer import script.
  - Remove references to old import script.
  - Fix changes that cause overwriting of existing entries.
  - Fix inappropriate ValidationError when defining networks with nested
    (but non-identical) address ranges. (LP: #1299114)
  - Fix issue where if a node does not provide an architecture type on dhcp
    request, or no other boot method is available for that architecture,
    the node still uses pxelinux.0 to boot. (LP: #1300285)
  - Take an advisory lock to prevent concurrent creation of the
    eventloops table. (LP: #1300363)
  - Remove the cloud_images_archive setting, as it conflicts with new
    import script. (LP: #1300587)
  - Add a 'logout confirmation' page. Using this, the logout action is
    protected against CSRF attacks because it uses a POST request, in
    conjunction with Django's CSRF protection feature. (LP: #1298790)
  - Fix cluster listings when dealing with large number of clusters by
    paginating it. (LP: #1301242)
  - Change list_boot_images() so that it can cope with a missing boot
    images directory: this happens if the reporting task runs before the
    images have been imported. (LP: #213984)
  - Fix internal server error on fast path installer. (LP: #1293676)
  - Fix uploading files using maas-cli. (LP: #1187826)
  - Fix SM15k Invalid Power Control and Fix enlisting machines with
    2.0 api. (LP: #1302818, LP: #1302819)

[ Andres Rodriguez ]
* debian/maas-cluster-controller.install: Install UEFI templates
* debian/maas-cluster-controller.dirs: Create 'boot-resources' dir.

[ Jason Hobbs ]
* debian/extras/99-maas: Allow access to keyserver.ubuntu.com via
  squid-deb-proxy.
 
[Jeroen Vermeulen]
* debian/maas-cluster-controller.postinst:
  - Make the tgt config link point to the new boot-resources dir.
* debian/maas-region-controller-min.dirs:
  - Don't create /var/lib/maas/tftp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from maasserver.enum import (
24
24
    COMMISSIONING_DISTRO_SERIES_CHOICES,
25
25
    DISTRO_SERIES,
26
 
    NODEGROUP_STATUS,
27
26
    )
28
27
from maasserver.models import (
29
28
    Config,
30
 
    nodegroup as nodegroup_module,
31
29
    UserProfile,
32
30
    )
33
31
from maasserver.testing import (
37
35
    )
38
36
from maasserver.testing.factory import factory
39
37
from maasserver.testing.testcase import MAASServerTestCase
40
 
from mock import (
41
 
    ANY,
42
 
    call,
43
 
    )
44
38
 
45
39
 
46
40
class SettingsTest(MAASServerTestCase):
145
139
        self.client_log_in(as_admin=True)
146
140
        new_main_archive = 'http://test.example.com/archive'
147
141
        new_ports_archive = 'http://test2.example.com/archive'
148
 
        new_cloud_images_archive = 'http://test3.example.com/archive'
149
142
        new_default_distro_series = factory.getRandomEnum(DISTRO_SERIES)
150
143
        response = self.client.post(
151
144
            reverse('settings'),
154
147
                data={
155
148
                    'main_archive': new_main_archive,
156
149
                    'ports_archive': new_ports_archive,
157
 
                    'cloud_images_archive': new_cloud_images_archive,
158
150
                    'default_distro_series': new_default_distro_series,
159
151
                }))
160
152
 
163
155
            (
164
156
                new_main_archive,
165
157
                new_ports_archive,
166
 
                new_cloud_images_archive,
167
158
                new_default_distro_series,
168
159
            ),
169
160
            (
170
161
                Config.objects.get_config('main_archive'),
171
162
                Config.objects.get_config('ports_archive'),
172
 
                Config.objects.get_config('cloud_images_archive'),
173
163
                Config.objects.get_config('default_distro_series'),
174
164
            ))
175
165
 
189
179
            new_kernel_opts,
190
180
            Config.objects.get_config('kernel_opts'))
191
181
 
192
 
    def test_settings_contains_form_to_accept_all_nodegroups(self):
193
 
        self.client_log_in(as_admin=True)
194
 
        factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
195
 
        response = self.client.get(reverse('settings'))
196
 
        doc = fromstring(response.content)
197
 
        forms = doc.cssselect('form#accept_all_pending_nodegroups')
198
 
        self.assertEqual(1, len(forms))
199
 
 
200
 
    def test_settings_contains_form_to_reject_all_nodegroups(self):
201
 
        self.client_log_in(as_admin=True)
202
 
        factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
203
 
        response = self.client.get(reverse('settings'))
204
 
        doc = fromstring(response.content)
205
 
        forms = doc.cssselect('form#reject_all_pending_nodegroups')
206
 
        self.assertEqual(1, len(forms))
207
 
 
208
 
    def test_settings_accepts_all_pending_nodegroups_POST(self):
209
 
        self.client_log_in(as_admin=True)
210
 
        nodegroups = {
211
 
            factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
212
 
            factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
213
 
        }
214
 
        response = self.client.post(
215
 
            reverse('settings'), {'mass_accept_submit': 1})
216
 
        self.assertEqual(httplib.FOUND, response.status_code)
217
 
        self.assertEqual(
218
 
            [reload_object(nodegroup).status for nodegroup in nodegroups],
219
 
            [NODEGROUP_STATUS.ACCEPTED] * 2)
220
 
 
221
 
    def test_settings_rejects_all_pending_nodegroups_POST(self):
222
 
        self.client_log_in(as_admin=True)
223
 
        nodegroups = {
224
 
            factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
225
 
            factory.make_node_group(status=NODEGROUP_STATUS.PENDING),
226
 
        }
227
 
        response = self.client.post(
228
 
            reverse('settings'), {'mass_reject_submit': 1})
229
 
        self.assertEqual(httplib.FOUND, response.status_code)
230
 
        self.assertEqual(
231
 
            [reload_object(nodegroup).status for nodegroup in nodegroups],
232
 
            [NODEGROUP_STATUS.REJECTED] * 2)
233
 
 
234
 
    def test_settings_import_boot_images_calls_tasks(self):
235
 
        self.client_log_in(as_admin=True)
236
 
        recorder = self.patch(nodegroup_module, 'import_boot_images')
237
 
        accepted_nodegroups = [
238
 
            factory.make_node_group(status=NODEGROUP_STATUS.ACCEPTED),
239
 
            factory.make_node_group(status=NODEGROUP_STATUS.ACCEPTED),
240
 
        ]
241
 
        response = self.client.post(
242
 
            reverse('settings'), {'import_all_boot_images': 1})
243
 
        self.assertEqual(httplib.FOUND, response.status_code)
244
 
        calls = [
245
 
            call(queue=nodegroup.work_queue, kwargs=ANY)
246
 
            for nodegroup in accepted_nodegroups
247
 
        ]
248
 
        self.assertItemsEqual(calls, recorder.apply_async.call_args_list)
249
 
 
250
 
    def test_cluster_no_boot_images_message_displayed_if_no_boot_images(self):
251
 
        self.client_log_in(as_admin=True)
252
 
        nodegroup = factory.make_node_group(
253
 
            status=NODEGROUP_STATUS.ACCEPTED)
254
 
        response = self.client.get(reverse('settings'))
255
 
        document = fromstring(response.content)
256
 
        nodegroup_row = document.xpath("//tr[@id='%s']" % nodegroup.uuid)[0]
257
 
        self.assertIn('no boot images', nodegroup_row.text_content())
258
 
 
259
182
 
260
183
class NonAdminSettingsTest(MAASServerTestCase):
261
184