Merge ~ines-almeida/launchpad:pro-enable-core18/update-logic into launchpad:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: e21dce7210480ec402e1ca4cb178352d6339ea2c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:pro-enable-core18/update-logic
Merge into: launchpad:master
Prerequisite: ~ines-almeida/launchpad:pro-enable-core18/update-models
Diff against target: 178 lines (+61/-2)
5 files modified
lib/lp/snappy/browser/snap.py (+2/-0)
lib/lp/snappy/browser/tests/test_snap.py (+3/-0)
lib/lp/snappy/model/snapbuildbehaviour.py (+9/-1)
lib/lp/snappy/tests/test_snap.py (+4/-0)
lib/lp/snappy/tests/test_snapbuildbehaviour.py (+43/-1)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+454035@code.launchpad.net

Commit message

Exclude archive dependencies that are private unless snap is pro_enable

Add 'pro_enable' attribute to snap admin UI

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
add27ba... by Ines Almeida

Prevent snap pro-enable test from failing once DB restriction patch is applied

e21dce7... by Ines Almeida

Fix typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
2index 96097fb..b783dcd 100644
3--- a/lib/lp/snappy/browser/snap.py
4+++ b/lib/lp/snappy/browser/snap.py
5@@ -524,6 +524,7 @@ class ISnapEditSchema(Interface):
6 "auto_build",
7 "auto_build_channels",
8 "store_upload",
9+ "pro_enable",
10 ],
11 )
12
13@@ -933,6 +934,7 @@ class SnapAdminView(BaseSnapEditView):
14 "information_type",
15 "require_virtualized",
16 "allow_internet",
17+ "pro_enable",
18 ]
19
20 @property
21diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
22index 1004c4c..2de0693 100644
23--- a/lib/lp/snappy/browser/tests/test_snap.py
24+++ b/lib/lp/snappy/browser/tests/test_snap.py
25@@ -834,6 +834,7 @@ class TestSnapAdminView(BaseTestSnapView):
26 self.assertIsNone(snap.project)
27 self.assertFalse(snap.private)
28 self.assertTrue(snap.allow_internet)
29+ self.assertFalse(snap.pro_enable)
30
31 self.factory.makeAccessPolicy(
32 pillar=project, type=InformationType.PRIVATESECURITY
33@@ -845,6 +846,7 @@ class TestSnapAdminView(BaseTestSnapView):
34 browser.getControl("Require virtualized builders").selected = False
35 browser.getControl(name="field.information_type").value = private
36 browser.getControl("Allow external network access").selected = False
37+ browser.getControl("Enable Ubuntu Pro").selected = True
38 browser.getControl("Update snap package").click()
39
40 login_admin()
41@@ -852,6 +854,7 @@ class TestSnapAdminView(BaseTestSnapView):
42 self.assertFalse(snap.require_virtualized)
43 self.assertTrue(snap.private)
44 self.assertFalse(snap.allow_internet)
45+ self.assertTrue(snap.pro_enable)
46
47 def test_admin_snap_private_without_project(self):
48 # Cannot make snap private if it doesn't have a project associated.
49diff --git a/lib/lp/snappy/model/snapbuildbehaviour.py b/lib/lp/snappy/model/snapbuildbehaviour.py
50index 7d40251..39d8238 100644
51--- a/lib/lp/snappy/model/snapbuildbehaviour.py
52+++ b/lib/lp/snappy/model/snapbuildbehaviour.py
53@@ -137,7 +137,15 @@ class SnapBuildBehaviour(BuilderProxyMixin, BuildFarmJobBehaviourBase):
54 tools_fingerprint = None
55 archive_dependencies = list(build.archive.dependencies)
56 if build.snap_base is not None:
57- archive_dependencies.extend(build.snap_base.dependencies)
58+ # Private dependencies are only listed for pro-enabled snaps
59+ archive_dependencies.extend(
60+ [
61+ dependency
62+ for dependency in build.snap_base.dependencies
63+ if build.snap.pro_enable
64+ or not dependency.dependency.private
65+ ]
66+ )
67 (
68 args["archives"],
69 args["trusted_keys"],
70diff --git a/lib/lp/snappy/tests/test_snap.py b/lib/lp/snappy/tests/test_snap.py
71index 665d1d8..f94ab74 100644
72--- a/lib/lp/snappy/tests/test_snap.py
73+++ b/lib/lp/snappy/tests/test_snap.py
74@@ -2321,6 +2321,7 @@ class TestSnapSet(TestCaseWithFactory):
75 self.assertFalse(snap.private)
76 self.assertTrue(snap.allow_internet)
77 self.assertFalse(snap.build_source_tarball)
78+ self.assertFalse(snap.pro_enable)
79
80 def test_creation_git(self):
81 # The metadata entries supplied when a Snap is created for a Git
82@@ -2344,6 +2345,7 @@ class TestSnapSet(TestCaseWithFactory):
83 self.assertFalse(snap.private)
84 self.assertTrue(snap.allow_internet)
85 self.assertFalse(snap.build_source_tarball)
86+ self.assertFalse(snap.pro_enable)
87
88 def test_creation_git_url(self):
89 # A Snap can be backed directly by a URL for an external Git
90@@ -3789,6 +3791,7 @@ class TestSnapWebservice(TestCaseWithFactory):
91 self.assertTrue(snap["require_virtualized"])
92 self.assertTrue(snap["allow_internet"])
93 self.assertFalse(snap["build_source_tarball"])
94+ self.assertFalse(snap["pro_enable"])
95
96 def test_new_git(self):
97 # Ensure Snap creation based on a Git branch works.
98@@ -3814,6 +3817,7 @@ class TestSnapWebservice(TestCaseWithFactory):
99 self.assertTrue(snap["require_virtualized"])
100 self.assertTrue(snap["allow_internet"])
101 self.assertFalse(snap["build_source_tarball"])
102+ self.assertFalse(snap["pro_enable"])
103
104 def test_new_private(self):
105 # Ensure private Snap creation works.
106diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
107index 1f5aeb6..1729666 100644
108--- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
109+++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
110@@ -973,7 +973,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
111 @defer.inlineCallbacks
112 def test_extraBuildArgs_snap_base_with_private_archive_dependencies(self):
113 # If the build is using a snap base that has archive dependencies on
114- # private PPAs, extraBuildArgs sends them.
115+ # private PPAs, extraBuildArgs excludes them.
116 self.useFixture(InProcessAuthServerFixture())
117 self.pushConfig(
118 "launchpad", internal_macaroon_secret_key="some-secret"
119@@ -997,10 +997,51 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
120 with dbuser(config.builddmaster.dbuser):
121 args = yield job.extraBuildArgs()
122 job.build.updateStatus(BuildStatus.BUILDING)
123+
124+ expected_archives = [
125+ "deb %s %s main universe"
126+ % (job.archive.archive_url, job.build.distro_series.name),
127+ "deb %s %s-security main universe"
128+ % (job.archive.archive_url, job.build.distro_series.name),
129+ "deb %s %s-updates main universe"
130+ % (job.archive.archive_url, job.build.distro_series.name),
131+ ]
132+ self.assertEqual(expected_archives, args["archives"])
133+
134+ @defer.inlineCallbacks
135+ def test_extraBuildArgs_pro_enabled_snap_base_private_dependencies(self):
136+ # If the build is using a snap base that has archive dependencies on
137+ # private PPAs, extraBuildArgs doesn't exclude them if snap base is
138+ # pro-enabled
139+ self.useFixture(InProcessAuthServerFixture())
140+ self.pushConfig(
141+ "launchpad", internal_macaroon_secret_key="some-secret"
142+ )
143+ snap_base = self.factory.makeSnapBase()
144+ job = self.makeJob(snap_base=snap_base, pro_enable=True)
145+ dependency = self.factory.makeArchive(
146+ distribution=job.archive.distribution, private=True
147+ )
148+ snap_base.addArchiveDependency(
149+ dependency,
150+ PackagePublishingPocket.RELEASE,
151+ getUtility(IComponentSet)["main"],
152+ )
153+ self.factory.makeBinaryPackagePublishingHistory(
154+ archive=dependency,
155+ distroarchseries=job.build.distro_arch_series,
156+ pocket=PackagePublishingPocket.RELEASE,
157+ status=PackagePublishingStatus.PUBLISHED,
158+ )
159+ with dbuser(config.builddmaster.dbuser):
160+ args = yield job.extraBuildArgs()
161+ job.build.updateStatus(BuildStatus.BUILDING)
162+
163 self.assertThat(
164 [SourceEntry(item) for item in args["archives"]],
165 MatchesListwise(
166 [
167+ # Private dependency
168 MatchesStructure(
169 type=Equals("deb"),
170 uri=AfterPreprocessing(
171@@ -1025,6 +1066,7 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, TestSnapBuildBehaviourBase):
172 dist=Equals(job.build.distro_series.name),
173 comps=Equals(["main"]),
174 ),
175+ # Non private dependencies
176 MatchesStructure.byEquality(
177 type="deb",
178 uri=job.archive.archive_url,

Subscribers

People subscribed via source and target branches

to status/vote changes: