launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27068
[Merge] launchpad:master into launchpad:db-devel
Colin Watson has proposed merging launchpad:master into launchpad:db-devel.
Commit message:
Manually merge from master to fix test_bzrsync.TestMarkSnapsStale failures
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1927946 in Launchpad itself: "Converting public +snap to private in one step leads to an OOPS"
https://bugs.launchpad.net/launchpad/+bug/1927946
For more details, see:
https://code.launchpad.net/~launchpad/launchpad/+git/launchpad/+merge/402985
These sneaked through to db-devel due to a buildbot subunit parsing bug of some kind.
--
Your team Launchpad code reviewers is requested to review the proposed merge of launchpad:master into launchpad:db-devel.
diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py
index 452bf4e..c9a98cd 100644
--- a/lib/lp/code/model/branch.py
+++ b/lib/lp/code/model/branch.py
@@ -689,7 +689,9 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
self,
check_permissions=False)
for snap in snaps:
- snap.is_stale = True
+ # ISnapSet.findByBranch returns security-proxied Snap objects on
+ # which the is_stale attribute is read-only. Bypass this.
+ removeSecurityProxy(snap).is_stale = True
def addToLaunchBag(self, launchbag):
"""See `IBranch`."""
diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
index ac7925c..c7b0ea3 100644
--- a/lib/lp/snappy/browser/snap.py
+++ b/lib/lp/snappy/browser/snap.py
@@ -835,6 +835,10 @@ class BaseSnapEditView(SnapAuthorizeMixin, SnapInformationTypeMixin,
if 'store_channels' in data:
del data['store_channels']
need_store_reauth = self._needStoreReauth(data)
+ info_type = data.get('information_type')
+ if info_type and info_type != self.context.information_type:
+ self.context.information_type = info_type
+ del data['information_type']
self.updateContextFromData(data)
if need_store_reauth:
self.requestAuthorization(self.context)
diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
index 486e586..8a96e17 100644
--- a/lib/lp/snappy/browser/tests/test_snap.py
+++ b/lib/lp/snappy/browser/tests/test_snap.py
@@ -1150,6 +1150,35 @@ class TestSnapEditView(BaseTestSnapView):
"A public snap cannot have a private owner.",
extract_text(find_tags_by_class(browser.contents, "message")[1]))
+ def test_edit_public_snap_make_private_in_one_go(self):
+ # Move a public snap to a private owner and mark it private in one go
+ series = self.factory.makeUbuntuDistroSeries()
+ with admin_logged_in():
+ snappy_series = self.factory.makeSnappySeries(
+ usable_distro_series=[series])
+ login_person(self.person)
+ private_project = self.factory.makeProduct(
+ name='private-project',
+ owner=self.person, registrant=self.person,
+ information_type=InformationType.PROPRIETARY,
+ branch_sharing_policy=BranchSharingPolicy.PROPRIETARY)
+ snap = self.factory.makeSnap(
+ registrant=self.person, owner=self.person, distroseries=series,
+ store_series=snappy_series, project=private_project)
+ private_team = self.factory.makeTeam(
+ owner=self.person, visibility=PersonVisibility.PRIVATE)
+ private_team_name = private_team.name
+
+ browser = self.getViewBrowser(snap, user=self.person)
+ browser.getLink("Edit snap package").click()
+ browser.getControl("Owner").value = [private_team_name]
+ browser.getControl(name="field.information_type").value = (
+ "PROPRIETARY")
+ browser.getControl("Update snap package").click()
+
+ login_admin()
+ self.assertEqual(InformationType.PROPRIETARY, snap.information_type)
+
def test_edit_public_snap_private_branch(self):
series = self.factory.makeUbuntuDistroSeries()
with admin_logged_in():