← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/livefs-minimal-privacy into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/livefs-minimal-privacy into lp:launchpad.

Commit message:
Make LiveFS and LiveFSBuild implement IPrivacy, so that the privacy banner works.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/livefs-minimal-privacy/+merge/370759
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/livefs-minimal-privacy into lp:launchpad.
=== modified file 'lib/lp/soyuz/interfaces/livefs.py'
--- lib/lp/soyuz/interfaces/livefs.py	2019-06-12 10:59:25 +0000
+++ lib/lp/soyuz/interfaces/livefs.py	2019-07-30 10:36:05 +0000
@@ -59,6 +59,7 @@
 
 from lp import _
 from lp.app.errors import NameLookupFailed
+from lp.app.interfaces.launchpad import IPrivacy
 from lp.app.validators.name import name_validator
 from lp.registry.interfaces.distroseries import IDistroSeries
 from lp.registry.interfaces.person import IPerson
@@ -139,7 +140,7 @@
     """This live filesystem cannot be deleted."""
 
 
-class ILiveFSView(Interface):
+class ILiveFSView(IPrivacy):
     """`ILiveFS` attributes that require launchpad.View permission."""
 
     id = exported(Int(title=_("ID"), required=True, readonly=True))

=== modified file 'lib/lp/soyuz/interfaces/livefsbuild.py'
--- lib/lp/soyuz/interfaces/livefsbuild.py	2015-09-15 20:16:47 +0000
+++ lib/lp/soyuz/interfaces/livefsbuild.py	2019-07-30 10:36:05 +0000
@@ -1,4 +1,4 @@
-# Copyright 2014-2015 Canonical Ltd.  This software is licensed under the
+# Copyright 2014-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Live filesystem build interfaces."""
@@ -30,6 +30,7 @@
     )
 
 from lp import _
+from lp.app.interfaces.launchpad import IPrivacy
 from lp.buildmaster.interfaces.buildfarmjob import ISpecificBuildFarmJobSource
 from lp.buildmaster.interfaces.packagebuild import IPackageBuild
 from lp.registry.interfaces.person import IPerson
@@ -54,7 +55,7 @@
         required=True, readonly=True)
 
 
-class ILiveFSBuildView(IPackageBuild):
+class ILiveFSBuildView(IPackageBuild, IPrivacy):
     """`ILiveFSBuild` attributes that require launchpad.View permission."""
 
     requester = exported(Reference(

=== modified file 'lib/lp/soyuz/model/livefs.py'
--- lib/lp/soyuz/model/livefs.py	2019-06-12 10:59:25 +0000
+++ lib/lp/soyuz/model/livefs.py	2019-07-30 10:36:05 +0000
@@ -139,6 +139,13 @@
         self.keep_binary_files_days = keep_binary_files_days
 
     @property
+    def private(self):
+        """See `IPrivacy`."""
+        # A LiveFS has no privacy support of its own, but it is private if
+        # its owner is.
+        return self.owner.private
+
+    @property
     def keep_binary_files_days(self):
         """See `ILiveFS`."""
         # Rounding up preserves the "at least this many days" part of the

=== modified file 'lib/lp/soyuz/model/livefsbuild.py'
--- lib/lp/soyuz/model/livefsbuild.py	2017-07-18 16:22:03 +0000
+++ lib/lp/soyuz/model/livefsbuild.py	2019-07-30 10:36:05 +0000
@@ -1,4 +1,4 @@
-# Copyright 2014-2017 Canonical Ltd.  This software is licensed under the
+# Copyright 2014-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -171,6 +171,8 @@
         """See `IBuildFarmJob`."""
         return self.livefs.owner.private or self.archive.private
 
+    private = is_private
+
     @property
     def title(self):
         das = self.distro_arch_series

=== modified file 'lib/lp/soyuz/tests/test_livefs.py'
--- lib/lp/soyuz/tests/test_livefs.py	2019-06-12 10:59:25 +0000
+++ lib/lp/soyuz/tests/test_livefs.py	2019-07-30 10:36:05 +0000
@@ -20,6 +20,7 @@
 from zope.security.interfaces import Unauthorized
 from zope.security.proxy import removeSecurityProxy
 
+from lp.app.interfaces.launchpad import IPrivacy
 from lp.buildmaster.enums import (
     BuildQueueStatus,
     BuildStatus,
@@ -85,10 +86,11 @@
         self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"}))
 
     def test_implements_interfaces(self):
-        # LiveFS implements ILiveFS.
+        # LiveFS implements ILiveFS and IPrivacy.
         livefs = self.factory.makeLiveFS()
         with person_logged_in(livefs.owner):
             self.assertProvides(livefs, ILiveFS)
+            self.assertProvides(livefs, IPrivacy)
 
     def test_avoids_problematic_snapshots(self):
         self.assertThat(
@@ -112,6 +114,20 @@
         self.assertSqlAttributeEqualsDate(
             livefs, "date_last_modified", UTC_NOW)
 
+    def test_private_owner(self):
+        # A LiveFS is private if its owner is.
+        person = self.factory.makePerson()
+        team = self.factory.makeTeam(
+            owner=person, visibility=PersonVisibility.PRIVATE)
+        with person_logged_in(person):
+            livefs = self.factory.makeLiveFS(registrant=person, owner=team)
+            self.assertTrue(livefs.private)
+
+    def test_public(self):
+        # A LiveFS is public if its owner is.
+        livefs = self.factory.makeLiveFS()
+        self.assertFalse(livefs.private)
+
     def test_relative_build_score(self):
         # Buildd admins can change the relative build score of a LiveFS, but
         # ordinary users cannot.
@@ -665,7 +681,10 @@
             private=True)
         archive_url = api_url(archive)
         livefs, _ = self.makeLiveFS(distroseries=distroseries)
-        response = self.webservice.named_post(
+        private_webservice = webservice_for_person(
+            self.person, permission=OAuthPermission.WRITE_PRIVATE)
+        private_webservice.default_api_version = "devel"
+        response = private_webservice.named_post(
             livefs["self_link"], "requestBuild", archive=archive_url,
             distro_arch_series=distroarchseries_url, pocket="Release")
         self.assertEqual(201, response.status)

=== modified file 'lib/lp/soyuz/tests/test_livefsbuild.py'
--- lib/lp/soyuz/tests/test_livefsbuild.py	2019-05-22 14:57:45 +0000
+++ lib/lp/soyuz/tests/test_livefsbuild.py	2019-07-30 10:36:05 +0000
@@ -1,4 +1,4 @@
-# Copyright 2014-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2014-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test live filesystem build features."""
@@ -21,7 +21,10 @@
 from zope.security.proxy import removeSecurityProxy
 
 from lp.app.errors import NotFoundError
-from lp.app.interfaces.launchpad import ILaunchpadCelebrities
+from lp.app.interfaces.launchpad import (
+    ILaunchpadCelebrities,
+    IPrivacy,
+    )
 from lp.buildmaster.enums import BuildStatus
 from lp.buildmaster.interfaces.buildqueue import IBuildQueue
 from lp.buildmaster.interfaces.packagebuild import IPackageBuild
@@ -96,9 +99,10 @@
         self.build = self.factory.makeLiveFSBuild()
 
     def test_implements_interfaces(self):
-        # LiveFSBuild implements IPackageBuild and ILiveFSBuild.
+        # LiveFSBuild implements IPackageBuild, ILiveFSBuild, and IPrivacy.
         self.assertProvides(self.build, IPackageBuild)
         self.assertProvides(self.build, ILiveFSBuild)
+        self.assertProvides(self.build, IPrivacy)
 
     def test_queueBuild(self):
         # LiveFSBuild can create the queue entry for itself.
@@ -127,16 +131,19 @@
     def test_is_private(self):
         # A LiveFSBuild is private iff its LiveFS and archive are.
         self.assertFalse(self.build.is_private)
+        self.assertFalse(self.build.private)
         private_team = self.factory.makeTeam(
             visibility=PersonVisibility.PRIVATE)
         with person_logged_in(private_team.teamowner):
             build = self.factory.makeLiveFSBuild(
                 requester=private_team.teamowner, owner=private_team)
             self.assertTrue(build.is_private)
+            self.assertTrue(build.private)
         private_archive = self.factory.makeArchive(private=True)
         with person_logged_in(private_archive.owner):
             build = self.factory.makeLiveFSBuild(archive=private_archive)
             self.assertTrue(build.is_private)
+            self.assertTrue(build.private)
 
     def test_can_be_cancelled(self):
         # For all states that can be cancelled, can_be_cancelled returns True.


Follow ups