Merge ~cjwatson/launchpad:fix-bpb-librarian-auth into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 60aaf6718cb2bfe28184198f804b70e7ba8a82bb
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-bpb-librarian-auth
Merge into: launchpad:master
Diff against target: 44 lines (+8/-3)
3 files modified
lib/lp/buildmaster/interactor.py (+6/-1)
lib/lp/soyuz/model/binarypackagebuildbehaviour.py (+1/-1)
lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py (+1/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+430027@code.launchpad.net

Commit message

Fix librarian URL generation for binary package builds

Description of the change

`LibraryFileAlias.https_url` is (confusingly) not the right thing to use here, since it just takes the HTTP URL and unconditionally replaces its scheme with "https". We need to use `getURL()` instead, which uses `https_url` for public files and constructs a URL on the appropriate restricted domain for private files.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
2index 3fe83c6..cd46eb4 100644
3--- a/lib/lp/buildmaster/interactor.py
4+++ b/lib/lp/buildmaster/interactor.py
5@@ -326,7 +326,12 @@ class BuilderWorker:
6 if logger is not None:
7 logger.info(
8 "Asking %s to ensure it has %s (%s%s)"
9- % (self.url, sha1, url, " with auth" if username else "")
10+ % (
11+ self.url,
12+ sha1,
13+ url,
14+ " with auth" if username or password else "",
15+ )
16 )
17 present, info = yield self.ensurepresent(sha1, url, username, password)
18 if not present:
19diff --git a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
20index 9cef29a..15f374d 100644
21--- a/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
22+++ b/lib/lp/soyuz/model/binarypackagebuildbehaviour.py
23@@ -74,7 +74,7 @@ class BinaryPackageBuildBehaviour(BuildFarmJobBehaviourBase):
24 lfa = source_file.libraryfile
25 filemap[lfa.filename] = {
26 "sha1": lfa.content.sha1,
27- "url": lfa.https_url,
28+ "url": lfa.getURL(),
29 }
30 if self.build.archive.private:
31 if macaroon_raw is None:
32diff --git a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
33index f3625ec..8f4d199 100644
34--- a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
35+++ b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
36@@ -147,7 +147,7 @@ class TestBinaryBuildPackageBehaviour(StatsMixin, TestCaseWithFactory):
37 )
38 else:
39 password = ""
40- uploads.append((sprf.libraryfile.https_url, "", password))
41+ uploads.append((sprf.libraryfile.getURL(), "", password))
42 upload_logs = [
43 MatchesListwise(
44 [Equals("ensurepresent")]

Subscribers

People subscribed via source and target branches

to status/vote changes: