← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/no-string-in-mime into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/no-string-in-mime into lp:maas.

Commit message:
Check the body being dispatched by parsing it with Django's multipart parser.

Previously the check was along the lines of "needle in multipart/form-data haystack", but now the haystack is mostly base64 encoded this does not work.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~allenap/maas/no-string-in-mime/+merge/126248
-- 
https://code.launchpad.net/~allenap/maas/no-string-in-mime/+merge/126248
Your team MAAS Maintainers is requested to review the proposed merge of lp:~allenap/maas/no-string-in-mime into lp:maas.
=== modified file 'src/provisioningserver/tests/test_start_cluster_controller.py'
--- src/provisioningserver/tests/test_start_cluster_controller.py	2012-09-25 10:42:00 +0000
+++ src/provisioningserver/tests/test_start_cluster_controller.py	2012-09-25 14:03:26 +0000
@@ -23,6 +23,8 @@
     )
 
 from apiclient.maas_client import MAASDispatcher
+from apiclient.testing.django import parse_headers_and_body_with_django
+from fixtures import EnvironmentVariableFixture
 from maastesting.factory import factory
 from provisioningserver import start_cluster_controller
 from provisioningserver.testing.testcase import PservTestCase
@@ -162,7 +164,15 @@
         (args, kwargs) = MAASDispatcher.dispatch_query.call_args
         self.assertEqual(url + 'api/1.0/nodegroups', args[0])
         self.assertEqual('POST', kwargs['method'])
-        self.assertIn('refresh_workers', kwargs['data'])
+
+        # Make Django STFU.
+        self.useFixture(
+            EnvironmentVariableFixture(
+                "DJANGO_SETTINGS_MODULE", __name__))
+
+        headers, body = kwargs["headers"], kwargs["data"]
+        post, files = parse_headers_and_body_with_django(headers, body)
+        self.assertEqual("refresh_workers", post["op"])
 
     def test_start_up_ignores_failure_on_refresh_secrets(self):
         self.patch(start_cluster_controller, 'Popen')