← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master

 

Andrey Fedoseev has proposed merging ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master.

Commit message:
Remove security proxy from `target_architectures`

Otherwise, it can't be marshalled for XML-RPC

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/425588
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~andrey-fedoseev/launchpad:snap-target-architectures into launchpad:master.
diff --git a/lib/lp/snappy/model/snapbuildbehaviour.py b/lib/lp/snappy/model/snapbuildbehaviour.py
index 612e963..3803efb 100644
--- a/lib/lp/snappy/model/snapbuildbehaviour.py
+++ b/lib/lp/snappy/model/snapbuildbehaviour.py
@@ -168,7 +168,9 @@ class SnapBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
             timestamp = format_as_rfc3339(build_request.date_requested)
             args["build_request_timestamp"] = timestamp
 
-        args["target_architectures"] = build.target_architectures
+        args["target_architectures"] = removeSecurityProxy(
+            build.target_architectures
+        )
 
         return args
 
diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
index 618c741..c63733d 100644
--- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
+++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
@@ -33,6 +33,7 @@ from testtools.twistedsupport import (
 from twisted.internet import defer
 from zope.component import getUtility
 from zope.proxy import isProxy
+from zope.security._proxy import _Proxy
 from zope.security.proxy import removeSecurityProxy
 
 from lp.app.enums import InformationType
@@ -327,6 +328,21 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
             ]))
 
     @defer.inlineCallbacks
+    def test_extraBuildArgs_no_security_proxy(self):
+        # The result of  `extraBuildArgs` must not contain values wrapped with
+        # zope security proxy because they can't be marshalled for XML-RPC
+        # requests.
+        snap = self.factory.makeSnap()
+        request = self.factory.makeSnapBuildRequest(snap=snap)
+        job = self.makeJob(snap=snap, build_request=request)
+        with dbuser(config.builddmaster.dbuser):
+            args = yield job.extraBuildArgs()
+        for key, value in args.items():
+            self.assertNotIsInstance(
+                value, _Proxy, "{} is a security proxy".format(key)
+            )
+
+    @defer.inlineCallbacks
     def test_extraBuildArgs_bzr(self):
         # extraBuildArgs returns appropriate arguments if asked to build a
         # job for a Bazaar branch.