Merge ~ilasc/launchpad:move-getPublishedBinaries-to-IArchiveSubscriberView into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: d71387851a0c0ab1434fdc2f3e77b2ad75f87265
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:move-getPublishedBinaries-to-IArchiveSubscriberView
Merge into: launchpad:master
Diff against target: 215 lines (+106/-80)
2 files modified
lib/lp/soyuz/browser/tests/test_archive_webservice.py (+26/-0)
lib/lp/soyuz/interfaces/archive.py (+80/-80)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+406709@code.launchpad.net

Commit message

Move getPublishedBinaries to IArchiveSubscriberView

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

This is fine per the investigation of why `getPublishedSources` and `getPublishedBinaries` ended up being different (`getPublishedSources` was moved in response to https://bugs.launchpad.net/launchpad/+bug/599286; apparently we don't necessarily want subscribers to be able to see things like build information, but since they can see the published archive it should be fine for them to search for published binaries).

However, could you please add a test for the changed behaviour? It could go in `lp.soyuz.browser.tests.test_archive_webservice.TestGetPublishedBinaries`.

review: Approve
Revision history for this message
Ioana Lasc (ilasc) wrote :

Good point Colin, added unit tests, thanks!

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/soyuz/browser/tests/test_archive_webservice.py b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
2index c404f6e..96d217f 100644
3--- a/lib/lp/soyuz/browser/tests/test_archive_webservice.py
4+++ b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
5@@ -697,6 +697,32 @@ class TestGetPublishedBinaries(TestCaseWithFactory):
6 self.assertEqual(200, response.status)
7 self.assertEqual(1, response.jsonBody()["total_size"])
8
9+ def test_getPublishedBinaries_private_subscriber(self):
10+ # Subscribers can see published binaries for private archives.
11+ private_archive = self.factory.makeArchive(private=True)
12+ with admin_logged_in():
13+ self.factory.makeBinaryPackagePublishingHistory(
14+ archive=private_archive)
15+ subscriber = self.factory.makePerson()
16+ with person_logged_in(private_archive.owner):
17+ private_archive.newSubscription(subscriber, private_archive.owner)
18+ archive_url = api_url(private_archive)
19+ ws = webservice_for_person(
20+ subscriber, permission=OAuthPermission.READ_PRIVATE,
21+ default_api_version="devel")
22+ response = ws.named_get(archive_url, "getPublishedBinaries")
23+ self.assertEqual(200, response.status)
24+ self.assertEqual(1, response.jsonBody()["total_size"])
25+
26+ def test_getPublishedBinaries_private_non_subscriber(self):
27+ private_archive = self.factory.makeArchive(private=True)
28+ archive_url = api_url(private_archive)
29+ ws = webservice_for_person(
30+ self.factory.makePerson(), permission=OAuthPermission.READ_PRIVATE,
31+ default_api_version="devel")
32+ response = ws.named_get(archive_url, "getPublishedBinaries")
33+ self.assertEqual(401, response.status)
34+
35 def test_getPublishedBinaries_created_since_date(self):
36 datecreated = self.factory.getUniqueDate()
37 later_date = datecreated + timedelta(minutes=1)
38diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py
39index 1752ba3..9f60d5d 100644
40--- a/lib/lp/soyuz/interfaces/archive.py
41+++ b/lib/lp/soyuz/interfaces/archive.py
42@@ -590,6 +590,86 @@ class IArchiveSubscriberView(Interface):
43 :return: A new IArchiveAuthToken
44 """
45
46+ @call_with(eager_load=True)
47+ @rename_parameters_as(
48+ name="binary_name", distroarchseries="distro_arch_series")
49+ @operation_parameters(
50+ name=TextLine(title=_("Binary Package Name"), required=False),
51+ version=TextLine(title=_("Version"), required=False),
52+ status=Choice(
53+ title=_("Package Publishing Status"),
54+ description=_("The status of this publishing record"),
55+ vocabulary=PackagePublishingStatus,
56+ required=False),
57+ distroarchseries=Reference(
58+ # Really IDistroArchSeries, circular import fixed below.
59+ Interface,
60+ title=_("Distro Arch Series"), required=False),
61+ pocket=Choice(
62+ title=_("Pocket"),
63+ description=_("The pocket into which this entry is published"),
64+ vocabulary=PackagePublishingPocket,
65+ required=False, readonly=True),
66+ exact_match=Bool(
67+ description=_("Whether or not to filter binary names by exact "
68+ "matching."),
69+ required=False),
70+ created_since_date=Datetime(
71+ title=_("Created Since Date"),
72+ description=_("Return entries whose `date_created` is greater "
73+ "than or equal to this date."),
74+ required=False),
75+ ordered=Bool(
76+ title=_("Ordered"),
77+ description=_("Return ordered results by default, but specifying "
78+ "False will return results more quickly."),
79+ required=False, readonly=True),
80+ order_by_date=Bool(
81+ title=_("Order by creation date"),
82+ description=_("Return newest results first. This is recommended "
83+ "for applications that need to catch up with "
84+ "publications since their last run."),
85+ required=False),
86+ )
87+ # Really returns IBinaryPackagePublishingHistory, see below for
88+ # patch to avoid circular import.
89+ @operation_returns_collection_of(Interface)
90+ @export_operation_as("getPublishedBinaries")
91+ @export_read_operation()
92+ def getAllPublishedBinaries(name=None, version=None, status=None,
93+ distroarchseries=None, pocket=None,
94+ exact_match=False, created_since_date=None,
95+ ordered=True, order_by_date=False,
96+ include_removed=True, only_unpublished=False,
97+ eager_load=False):
98+ """All `IBinaryPackagePublishingHistory` target to this archive.
99+
100+ :param name: binary name filter (exact match or SQL LIKE controlled
101+ by 'exact_match' argument).
102+ :param version: binary version filter (always exact match).
103+ :param status: `PackagePublishingStatus` filter, can be a list.
104+ :param distroarchseries: `IDistroArchSeries` filter, can be a list.
105+ :param pocket: `PackagePublishingPocket` filter.
106+ :param exact_match: either or not filter source names by exact
107+ matching.
108+ :param created_since_date: Only return publications created on or
109+ after this date.
110+ :param ordered: Normally publications are ordered by binary package
111+ name and then ID order (creation order). If this parameter is
112+ False then the results will be unordered. This will make the
113+ operation much quicker to return results if you don't care about
114+ ordering.
115+ :param order_by_date: Order publications by descending creation date
116+ and then by descending ID. This is suitable for applications
117+ that need to catch up with publications since their last run.
118+ :param include_removed: If True, include publications that have been
119+ removed from disk as well as those that have not.
120+ :param only_unpublished: If True, only include publications that
121+ have never been published to disk.
122+
123+ :return: A collection containing `BinaryPackagePublishingHistory`.
124+ """
125+
126
127 class IArchiveView(IHasBuildRecords):
128 """Archive interface for operations restricted by view privilege."""
129@@ -1191,86 +1271,6 @@ class IArchiveView(IHasBuildRecords):
130 def getOverridePolicy(distroseries, pocket, phased_update_percentage=None):
131 """Returns an instantiated `IOverridePolicy` for the archive."""
132
133- @call_with(eager_load=True)
134- @rename_parameters_as(
135- name="binary_name", distroarchseries="distro_arch_series")
136- @operation_parameters(
137- name=TextLine(title=_("Binary Package Name"), required=False),
138- version=TextLine(title=_("Version"), required=False),
139- status=Choice(
140- title=_("Package Publishing Status"),
141- description=_("The status of this publishing record"),
142- vocabulary=PackagePublishingStatus,
143- required=False),
144- distroarchseries=Reference(
145- # Really IDistroArchSeries, circular import fixed below.
146- Interface,
147- title=_("Distro Arch Series"), required=False),
148- pocket=Choice(
149- title=_("Pocket"),
150- description=_("The pocket into which this entry is published"),
151- vocabulary=PackagePublishingPocket,
152- required=False, readonly=True),
153- exact_match=Bool(
154- description=_("Whether or not to filter binary names by exact "
155- "matching."),
156- required=False),
157- created_since_date=Datetime(
158- title=_("Created Since Date"),
159- description=_("Return entries whose `date_created` is greater "
160- "than or equal to this date."),
161- required=False),
162- ordered=Bool(
163- title=_("Ordered"),
164- description=_("Return ordered results by default, but specifying "
165- "False will return results more quickly."),
166- required=False, readonly=True),
167- order_by_date=Bool(
168- title=_("Order by creation date"),
169- description=_("Return newest results first. This is recommended "
170- "for applications that need to catch up with "
171- "publications since their last run."),
172- required=False),
173- )
174- # Really returns IBinaryPackagePublishingHistory, see below for
175- # patch to avoid circular import.
176- @operation_returns_collection_of(Interface)
177- @export_operation_as("getPublishedBinaries")
178- @export_read_operation()
179- def getAllPublishedBinaries(name=None, version=None, status=None,
180- distroarchseries=None, pocket=None,
181- exact_match=False, created_since_date=None,
182- ordered=True, order_by_date=False,
183- include_removed=True, only_unpublished=False,
184- eager_load=False):
185- """All `IBinaryPackagePublishingHistory` target to this archive.
186-
187- :param name: binary name filter (exact match or SQL LIKE controlled
188- by 'exact_match' argument).
189- :param version: binary version filter (always exact match).
190- :param status: `PackagePublishingStatus` filter, can be a list.
191- :param distroarchseries: `IDistroArchSeries` filter, can be a list.
192- :param pocket: `PackagePublishingPocket` filter.
193- :param exact_match: either or not filter source names by exact
194- matching.
195- :param created_since_date: Only return publications created on or
196- after this date.
197- :param ordered: Normally publications are ordered by binary package
198- name and then ID order (creation order). If this parameter is
199- False then the results will be unordered. This will make the
200- operation much quicker to return results if you don't care about
201- ordering.
202- :param order_by_date: Order publications by descending creation date
203- and then by descending ID. This is suitable for applications
204- that need to catch up with publications since their last run.
205- :param include_removed: If True, include publications that have been
206- removed from disk as well as those that have not.
207- :param only_unpublished: If True, only include publications that
208- have never been published to disk.
209-
210- :return: A collection containing `BinaryPackagePublishingHistory`.
211- """
212-
213 @operation_parameters(
214 include_needsbuild=Bool(
215 title=_("Include builds with state NEEDSBUILD"), required=False))

Subscribers

People subscribed via source and target branches

to status/vote changes: