Merge lp:~cjwatson/launchpad/livefs-minimal-privacy into lp:launchpad
- livefs-minimal-privacy
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 19033 |
Proposed branch: | lp:~cjwatson/launchpad/livefs-minimal-privacy |
Merge into: | lp:launchpad |
Diff against target: |
196 lines (+46/-9) 6 files modified
lib/lp/soyuz/interfaces/livefs.py (+2/-1) lib/lp/soyuz/interfaces/livefsbuild.py (+3/-2) lib/lp/soyuz/model/livefs.py (+7/-0) lib/lp/soyuz/model/livefsbuild.py (+3/-1) lib/lp/soyuz/tests/test_livefs.py (+21/-2) lib/lp/soyuz/tests/test_livefsbuild.py (+10/-3) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/livefs-minimal-privacy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+370759@code.launchpad.net |
Commit message
Make LiveFS and LiveFSBuild implement IPrivacy, so that the privacy banner works.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/soyuz/interfaces/livefs.py' | |||
2 | --- lib/lp/soyuz/interfaces/livefs.py 2019-06-12 10:59:25 +0000 | |||
3 | +++ lib/lp/soyuz/interfaces/livefs.py 2019-07-30 10:36:05 +0000 | |||
4 | @@ -59,6 +59,7 @@ | |||
5 | 59 | 59 | ||
6 | 60 | from lp import _ | 60 | from lp import _ |
7 | 61 | from lp.app.errors import NameLookupFailed | 61 | from lp.app.errors import NameLookupFailed |
8 | 62 | from lp.app.interfaces.launchpad import IPrivacy | ||
9 | 62 | from lp.app.validators.name import name_validator | 63 | from lp.app.validators.name import name_validator |
10 | 63 | from lp.registry.interfaces.distroseries import IDistroSeries | 64 | from lp.registry.interfaces.distroseries import IDistroSeries |
11 | 64 | from lp.registry.interfaces.person import IPerson | 65 | from lp.registry.interfaces.person import IPerson |
12 | @@ -139,7 +140,7 @@ | |||
13 | 139 | """This live filesystem cannot be deleted.""" | 140 | """This live filesystem cannot be deleted.""" |
14 | 140 | 141 | ||
15 | 141 | 142 | ||
17 | 142 | class ILiveFSView(Interface): | 143 | class ILiveFSView(IPrivacy): |
18 | 143 | """`ILiveFS` attributes that require launchpad.View permission.""" | 144 | """`ILiveFS` attributes that require launchpad.View permission.""" |
19 | 144 | 145 | ||
20 | 145 | id = exported(Int(title=_("ID"), required=True, readonly=True)) | 146 | id = exported(Int(title=_("ID"), required=True, readonly=True)) |
21 | 146 | 147 | ||
22 | === modified file 'lib/lp/soyuz/interfaces/livefsbuild.py' | |||
23 | --- lib/lp/soyuz/interfaces/livefsbuild.py 2015-09-15 20:16:47 +0000 | |||
24 | +++ lib/lp/soyuz/interfaces/livefsbuild.py 2019-07-30 10:36:05 +0000 | |||
25 | @@ -1,4 +1,4 @@ | |||
27 | 1 | # Copyright 2014-2015 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014-2019 Canonical Ltd. This software is licensed under the |
28 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
29 | 3 | 3 | ||
30 | 4 | """Live filesystem build interfaces.""" | 4 | """Live filesystem build interfaces.""" |
31 | @@ -30,6 +30,7 @@ | |||
32 | 30 | ) | 30 | ) |
33 | 31 | 31 | ||
34 | 32 | from lp import _ | 32 | from lp import _ |
35 | 33 | from lp.app.interfaces.launchpad import IPrivacy | ||
36 | 33 | from lp.buildmaster.interfaces.buildfarmjob import ISpecificBuildFarmJobSource | 34 | from lp.buildmaster.interfaces.buildfarmjob import ISpecificBuildFarmJobSource |
37 | 34 | from lp.buildmaster.interfaces.packagebuild import IPackageBuild | 35 | from lp.buildmaster.interfaces.packagebuild import IPackageBuild |
38 | 35 | from lp.registry.interfaces.person import IPerson | 36 | from lp.registry.interfaces.person import IPerson |
39 | @@ -54,7 +55,7 @@ | |||
40 | 54 | required=True, readonly=True) | 55 | required=True, readonly=True) |
41 | 55 | 56 | ||
42 | 56 | 57 | ||
44 | 57 | class ILiveFSBuildView(IPackageBuild): | 58 | class ILiveFSBuildView(IPackageBuild, IPrivacy): |
45 | 58 | """`ILiveFSBuild` attributes that require launchpad.View permission.""" | 59 | """`ILiveFSBuild` attributes that require launchpad.View permission.""" |
46 | 59 | 60 | ||
47 | 60 | requester = exported(Reference( | 61 | requester = exported(Reference( |
48 | 61 | 62 | ||
49 | === modified file 'lib/lp/soyuz/model/livefs.py' | |||
50 | --- lib/lp/soyuz/model/livefs.py 2019-06-12 10:59:25 +0000 | |||
51 | +++ lib/lp/soyuz/model/livefs.py 2019-07-30 10:36:05 +0000 | |||
52 | @@ -139,6 +139,13 @@ | |||
53 | 139 | self.keep_binary_files_days = keep_binary_files_days | 139 | self.keep_binary_files_days = keep_binary_files_days |
54 | 140 | 140 | ||
55 | 141 | @property | 141 | @property |
56 | 142 | def private(self): | ||
57 | 143 | """See `IPrivacy`.""" | ||
58 | 144 | # A LiveFS has no privacy support of its own, but it is private if | ||
59 | 145 | # its owner is. | ||
60 | 146 | return self.owner.private | ||
61 | 147 | |||
62 | 148 | @property | ||
63 | 142 | def keep_binary_files_days(self): | 149 | def keep_binary_files_days(self): |
64 | 143 | """See `ILiveFS`.""" | 150 | """See `ILiveFS`.""" |
65 | 144 | # Rounding up preserves the "at least this many days" part of the | 151 | # Rounding up preserves the "at least this many days" part of the |
66 | 145 | 152 | ||
67 | === modified file 'lib/lp/soyuz/model/livefsbuild.py' | |||
68 | --- lib/lp/soyuz/model/livefsbuild.py 2017-07-18 16:22:03 +0000 | |||
69 | +++ lib/lp/soyuz/model/livefsbuild.py 2019-07-30 10:36:05 +0000 | |||
70 | @@ -1,4 +1,4 @@ | |||
72 | 1 | # Copyright 2014-2017 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014-2019 Canonical Ltd. This software is licensed under the |
73 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
74 | 3 | 3 | ||
75 | 4 | __metaclass__ = type | 4 | __metaclass__ = type |
76 | @@ -171,6 +171,8 @@ | |||
77 | 171 | """See `IBuildFarmJob`.""" | 171 | """See `IBuildFarmJob`.""" |
78 | 172 | return self.livefs.owner.private or self.archive.private | 172 | return self.livefs.owner.private or self.archive.private |
79 | 173 | 173 | ||
80 | 174 | private = is_private | ||
81 | 175 | |||
82 | 174 | @property | 176 | @property |
83 | 175 | def title(self): | 177 | def title(self): |
84 | 176 | das = self.distro_arch_series | 178 | das = self.distro_arch_series |
85 | 177 | 179 | ||
86 | === modified file 'lib/lp/soyuz/tests/test_livefs.py' | |||
87 | --- lib/lp/soyuz/tests/test_livefs.py 2019-06-12 10:59:25 +0000 | |||
88 | +++ lib/lp/soyuz/tests/test_livefs.py 2019-07-30 10:36:05 +0000 | |||
89 | @@ -20,6 +20,7 @@ | |||
90 | 20 | from zope.security.interfaces import Unauthorized | 20 | from zope.security.interfaces import Unauthorized |
91 | 21 | from zope.security.proxy import removeSecurityProxy | 21 | from zope.security.proxy import removeSecurityProxy |
92 | 22 | 22 | ||
93 | 23 | from lp.app.interfaces.launchpad import IPrivacy | ||
94 | 23 | from lp.buildmaster.enums import ( | 24 | from lp.buildmaster.enums import ( |
95 | 24 | BuildQueueStatus, | 25 | BuildQueueStatus, |
96 | 25 | BuildStatus, | 26 | BuildStatus, |
97 | @@ -85,10 +86,11 @@ | |||
98 | 85 | self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) | 86 | self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
99 | 86 | 87 | ||
100 | 87 | def test_implements_interfaces(self): | 88 | def test_implements_interfaces(self): |
102 | 88 | # LiveFS implements ILiveFS. | 89 | # LiveFS implements ILiveFS and IPrivacy. |
103 | 89 | livefs = self.factory.makeLiveFS() | 90 | livefs = self.factory.makeLiveFS() |
104 | 90 | with person_logged_in(livefs.owner): | 91 | with person_logged_in(livefs.owner): |
105 | 91 | self.assertProvides(livefs, ILiveFS) | 92 | self.assertProvides(livefs, ILiveFS) |
106 | 93 | self.assertProvides(livefs, IPrivacy) | ||
107 | 92 | 94 | ||
108 | 93 | def test_avoids_problematic_snapshots(self): | 95 | def test_avoids_problematic_snapshots(self): |
109 | 94 | self.assertThat( | 96 | self.assertThat( |
110 | @@ -112,6 +114,20 @@ | |||
111 | 112 | self.assertSqlAttributeEqualsDate( | 114 | self.assertSqlAttributeEqualsDate( |
112 | 113 | livefs, "date_last_modified", UTC_NOW) | 115 | livefs, "date_last_modified", UTC_NOW) |
113 | 114 | 116 | ||
114 | 117 | def test_private_owner(self): | ||
115 | 118 | # A LiveFS is private if its owner is. | ||
116 | 119 | person = self.factory.makePerson() | ||
117 | 120 | team = self.factory.makeTeam( | ||
118 | 121 | owner=person, visibility=PersonVisibility.PRIVATE) | ||
119 | 122 | with person_logged_in(person): | ||
120 | 123 | livefs = self.factory.makeLiveFS(registrant=person, owner=team) | ||
121 | 124 | self.assertTrue(livefs.private) | ||
122 | 125 | |||
123 | 126 | def test_public(self): | ||
124 | 127 | # A LiveFS is public if its owner is. | ||
125 | 128 | livefs = self.factory.makeLiveFS() | ||
126 | 129 | self.assertFalse(livefs.private) | ||
127 | 130 | |||
128 | 115 | def test_relative_build_score(self): | 131 | def test_relative_build_score(self): |
129 | 116 | # Buildd admins can change the relative build score of a LiveFS, but | 132 | # Buildd admins can change the relative build score of a LiveFS, but |
130 | 117 | # ordinary users cannot. | 133 | # ordinary users cannot. |
131 | @@ -665,7 +681,10 @@ | |||
132 | 665 | private=True) | 681 | private=True) |
133 | 666 | archive_url = api_url(archive) | 682 | archive_url = api_url(archive) |
134 | 667 | livefs, _ = self.makeLiveFS(distroseries=distroseries) | 683 | livefs, _ = self.makeLiveFS(distroseries=distroseries) |
136 | 668 | response = self.webservice.named_post( | 684 | private_webservice = webservice_for_person( |
137 | 685 | self.person, permission=OAuthPermission.WRITE_PRIVATE) | ||
138 | 686 | private_webservice.default_api_version = "devel" | ||
139 | 687 | response = private_webservice.named_post( | ||
140 | 669 | livefs["self_link"], "requestBuild", archive=archive_url, | 688 | livefs["self_link"], "requestBuild", archive=archive_url, |
141 | 670 | distro_arch_series=distroarchseries_url, pocket="Release") | 689 | distro_arch_series=distroarchseries_url, pocket="Release") |
142 | 671 | self.assertEqual(201, response.status) | 690 | self.assertEqual(201, response.status) |
143 | 672 | 691 | ||
144 | === modified file 'lib/lp/soyuz/tests/test_livefsbuild.py' | |||
145 | --- lib/lp/soyuz/tests/test_livefsbuild.py 2019-05-22 14:57:45 +0000 | |||
146 | +++ lib/lp/soyuz/tests/test_livefsbuild.py 2019-07-30 10:36:05 +0000 | |||
147 | @@ -1,4 +1,4 @@ | |||
149 | 1 | # Copyright 2014-2018 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2014-2019 Canonical Ltd. This software is licensed under the |
150 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
151 | 3 | 3 | ||
152 | 4 | """Test live filesystem build features.""" | 4 | """Test live filesystem build features.""" |
153 | @@ -21,7 +21,10 @@ | |||
154 | 21 | from zope.security.proxy import removeSecurityProxy | 21 | from zope.security.proxy import removeSecurityProxy |
155 | 22 | 22 | ||
156 | 23 | from lp.app.errors import NotFoundError | 23 | from lp.app.errors import NotFoundError |
158 | 24 | from lp.app.interfaces.launchpad import ILaunchpadCelebrities | 24 | from lp.app.interfaces.launchpad import ( |
159 | 25 | ILaunchpadCelebrities, | ||
160 | 26 | IPrivacy, | ||
161 | 27 | ) | ||
162 | 25 | from lp.buildmaster.enums import BuildStatus | 28 | from lp.buildmaster.enums import BuildStatus |
163 | 26 | from lp.buildmaster.interfaces.buildqueue import IBuildQueue | 29 | from lp.buildmaster.interfaces.buildqueue import IBuildQueue |
164 | 27 | from lp.buildmaster.interfaces.packagebuild import IPackageBuild | 30 | from lp.buildmaster.interfaces.packagebuild import IPackageBuild |
165 | @@ -96,9 +99,10 @@ | |||
166 | 96 | self.build = self.factory.makeLiveFSBuild() | 99 | self.build = self.factory.makeLiveFSBuild() |
167 | 97 | 100 | ||
168 | 98 | def test_implements_interfaces(self): | 101 | def test_implements_interfaces(self): |
170 | 99 | # LiveFSBuild implements IPackageBuild and ILiveFSBuild. | 102 | # LiveFSBuild implements IPackageBuild, ILiveFSBuild, and IPrivacy. |
171 | 100 | self.assertProvides(self.build, IPackageBuild) | 103 | self.assertProvides(self.build, IPackageBuild) |
172 | 101 | self.assertProvides(self.build, ILiveFSBuild) | 104 | self.assertProvides(self.build, ILiveFSBuild) |
173 | 105 | self.assertProvides(self.build, IPrivacy) | ||
174 | 102 | 106 | ||
175 | 103 | def test_queueBuild(self): | 107 | def test_queueBuild(self): |
176 | 104 | # LiveFSBuild can create the queue entry for itself. | 108 | # LiveFSBuild can create the queue entry for itself. |
177 | @@ -127,16 +131,19 @@ | |||
178 | 127 | def test_is_private(self): | 131 | def test_is_private(self): |
179 | 128 | # A LiveFSBuild is private iff its LiveFS and archive are. | 132 | # A LiveFSBuild is private iff its LiveFS and archive are. |
180 | 129 | self.assertFalse(self.build.is_private) | 133 | self.assertFalse(self.build.is_private) |
181 | 134 | self.assertFalse(self.build.private) | ||
182 | 130 | private_team = self.factory.makeTeam( | 135 | private_team = self.factory.makeTeam( |
183 | 131 | visibility=PersonVisibility.PRIVATE) | 136 | visibility=PersonVisibility.PRIVATE) |
184 | 132 | with person_logged_in(private_team.teamowner): | 137 | with person_logged_in(private_team.teamowner): |
185 | 133 | build = self.factory.makeLiveFSBuild( | 138 | build = self.factory.makeLiveFSBuild( |
186 | 134 | requester=private_team.teamowner, owner=private_team) | 139 | requester=private_team.teamowner, owner=private_team) |
187 | 135 | self.assertTrue(build.is_private) | 140 | self.assertTrue(build.is_private) |
188 | 141 | self.assertTrue(build.private) | ||
189 | 136 | private_archive = self.factory.makeArchive(private=True) | 142 | private_archive = self.factory.makeArchive(private=True) |
190 | 137 | with person_logged_in(private_archive.owner): | 143 | with person_logged_in(private_archive.owner): |
191 | 138 | build = self.factory.makeLiveFSBuild(archive=private_archive) | 144 | build = self.factory.makeLiveFSBuild(archive=private_archive) |
192 | 139 | self.assertTrue(build.is_private) | 145 | self.assertTrue(build.is_private) |
193 | 146 | self.assertTrue(build.private) | ||
194 | 140 | 147 | ||
195 | 141 | def test_can_be_cancelled(self): | 148 | def test_can_be_cancelled(self): |
196 | 142 | # For all states that can be cancelled, can_be_cancelled returns True. | 149 | # For all states that can be cancelled, can_be_cancelled returns True. |
This isn't quite accurate, since the files' privacy doesn't follow the owner's, but that's rare enough that it probably doesn't matter.