Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/bug-645925 into 
lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
  #645925 Permission denied for relation translationtemplatesbuild
  https://bugs.launchpad.net/bugs/645925


= Bug 645925 =

We're making the transition to a new data model for the build farm.  We just 
landed a new class, TranslationTemplatesBuild that was one of the big missing 
tracts of this transition.

Instantiating this class in the branch scanner went wrong, however, because of 
missing database privileges.  This branch should fix that.
-- 
https://code.launchpad.net/~jtv/launchpad/bug-645925/+merge/36540
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~jtv/launchpad/bug-645925 into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2010-09-23 11:37:58 +0000
+++ database/schema/security.cfg	2010-09-24 10:39:53 +0000
@@ -276,7 +276,7 @@
 public.translationgroup                 = SELECT, INSERT, UPDATE
 public.translationimportqueueentry      = SELECT, INSERT, UPDATE, DELETE
 public.translationmessage               = SELECT, INSERT, UPDATE
-public.translationtemplatesbuild        = SELECT, INSERT, DELETE
+public.translationtemplatesbuild        = SELECT, INSERT, UPDATE, DELETE
 public.translator                       = SELECT, INSERT, UPDATE, DELETE
 public.usertouseremail                  = SELECT, UPDATE
 public.validpersoncache                 = SELECT
@@ -597,6 +597,7 @@
 public.distributionsourcepackage        = SELECT, UPDATE
 public.emailaddress                     = SELECT
 public.job                              = SELECT, INSERT, UPDATE, DELETE
+public.translationtemplatesbuild        = SELECT, INSERT
 # Karma
 public.karma                            = SELECT, INSERT
 public.karmaaction                      = SELECT
@@ -890,6 +891,7 @@
 public.flatpackagesetinclusion                  = SELECT
 public.teamparticipation                        = SELECT
 public.translationimportqueueentry              = SELECT, INSERT, UPDATE
+public.translationtemplatesbuild                = SELECT, INSERT
 
 [ppa-apache-log-parser]
 type=user
@@ -1441,7 +1443,6 @@
 [translationsbranchscanner]
 type=user
 groups=branchscanner,translations_approval
-public.translationtemplatesbuild        = SELECT, INSERT
 
 [translationstobranch]
 type=user

=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuild.py'
--- lib/lp/translations/tests/test_translationtemplatesbuild.py	2010-09-10 11:27:48 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuild.py	2010-09-24 10:39:53 +0000
@@ -5,10 +5,13 @@
 
 __metaclass__ = type
 
+from storm.store import Store
+import transaction
 from zope.component import getUtility
 from zope.interface.verify import verifyObject
 
-from canonical.testing import DatabaseFunctionalLayer
+from canonical.config import config
+from canonical.testing import LaunchpadZopelessLayer
 from lp.buildmaster.enums import BuildFarmJobType
 from lp.buildmaster.interfaces.buildfarmjob import (
     IBuildFarmJob,
@@ -29,7 +32,7 @@
 
 class TestTranslationTemplatesBuild(TestCaseWithFactory):
 
-    layer = DatabaseFunctionalLayer
+    layer = LaunchpadZopelessLayer
 
     def _makeBuildFarmJob(self):
         """Create a `BuildFarmJob` for testing."""
@@ -48,6 +51,20 @@
         self.assertEqual(build_farm_job, build.build_farm_job)
         self.assertEqual(branch, build.branch)
 
+    def test_permissions(self):
+        # The branch scanner creates TranslationTemplatesBuilds.  It has
+        # the database privileges it needs for that.
+        branch = self.factory.makeBranch()
+        transaction.commit()
+        self.layer.switchDbUser(config.branchscanner.dbuser)
+        utility = getUtility(ITranslationTemplatesBuildSource)
+        build_farm_job = self._makeBuildFarmJob()
+        specific_job = utility.create(build_farm_job, branch)
+
+        # Writing the new objects to the database violates no access
+        # restrictions.
+        Store.of(build_farm_job).flush()
+
     def test_created_by_buildjobsource(self):
         # ITranslationTemplatesBuildJobSource.create also creates a
         # TranslationTemplatesBuild.  This utility will become obsolete

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to