Merge lp:~cjwatson/launchpad/fix-packagediff-private into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merged at revision: 15627
Proposed branch: lp:~cjwatson/launchpad/fix-packagediff-private
Merge into: lp:launchpad
Diff against target: 96 lines (+27/-6)
4 files modified
lib/lp/soyuz/doc/package-diff.txt (+1/-1)
lib/lp/soyuz/model/packagediff.py (+3/-2)
lib/lp/soyuz/tests/soyuz.py (+2/-1)
lib/lp/soyuz/tests/test_packagediff.py (+21/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/fix-packagediff-private
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+114759@code.launchpad.net

Commit message

Make a PackageDiff public if any of its source's published archives are public.

Description of the change

== Summary ==

Bug 1023986: package diffs for security uploads are sometimes inappropriately private. I think this is because they've been generated against SPRs that were originally uploaded to a private archive, so PackageDiff incorrectly thinks that diffs against them need to be private even though they've since been unembargoed.

== Proposed fix ==

Check privacy of published_archives rather than of upload_archive.

== LOC Rationale ==

+21. I have 1625 lines of credit. Besides, this is probably part of the work to let us remove delayed copies and the ubuntu-security celebrity and suchlike, which should make up for it.

== Tests ==

bin/test -vvct test_packagediff

== Demo and Q/A ==

Upload a package whose ancestry is an SPR that was originally uploaded to a private archive (e.g. a security update) and check that its PackageDiffs are public.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the fix Colin

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/doc/package-diff.txt'
2--- lib/lp/soyuz/doc/package-diff.txt 2011-12-30 06:14:56 +0000
3+++ lib/lp/soyuz/doc/package-diff.txt 2012-07-14 16:56:21 +0000
4@@ -732,7 +732,7 @@
5
6 >>> private_ppa = factory.makeArchive(private=True)
7 >>> from zope.security.proxy import removeSecurityProxy
8- >>> removeSecurityProxy(diff.to_source).upload_archive = private_ppa
9+ >>> removeSecurityProxy(biscuit_two_pub).archive = private_ppa
10
11 >>> print diff.private
12 True
13
14=== modified file 'lib/lp/soyuz/model/packagediff.py'
15--- lib/lp/soyuz/model/packagediff.py 2012-04-16 23:02:44 +0000
16+++ lib/lp/soyuz/model/packagediff.py 2012-07-14 16:56:21 +0000
17@@ -1,4 +1,4 @@
18-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
19+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
20 # GNU Affero General Public License version 3 (see the file LICENSE).
21
22 __metaclass__ = type
23@@ -145,7 +145,8 @@
24 @property
25 def private(self):
26 """See `IPackageDiff`."""
27- return self.to_source.upload_archive.private
28+ return all(
29+ archive.private for archive in self.to_source.published_archives)
30
31 def _countDeletedLFAs(self):
32 """How many files associated with either source package have been
33
34=== modified file 'lib/lp/soyuz/tests/soyuz.py'
35--- lib/lp/soyuz/tests/soyuz.py 2012-01-06 11:08:30 +0000
36+++ lib/lp/soyuz/tests/soyuz.py 2012-07-14 16:56:21 +0000
37@@ -1,4 +1,4 @@
38-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
39+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42 """Helper functions/classes for Soyuz tests."""
43@@ -154,6 +154,7 @@
44 Store the `FakePackager` object used in the test uploads as `packager`
45 so the tests can reuse it if necessary.
46 """
47+ super(TestPackageDiffsBase, self).setUp()
48 with dbuser(LAUNCHPAD_DBUSER_NAME):
49 fake_chroot = LibraryFileAlias.get(CHROOT_LIBRARYFILEALIAS)
50 ubuntu = getUtility(IDistributionSet).getByName(
51
52=== modified file 'lib/lp/soyuz/tests/test_packagediff.py'
53--- lib/lp/soyuz/tests/test_packagediff.py 2011-12-30 06:14:56 +0000
54+++ lib/lp/soyuz/tests/test_packagediff.py 2012-07-14 16:56:21 +0000
55@@ -1,4 +1,4 @@
56-# Copyright 2010 Canonical Ltd. This software is licensed under the
57+# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
58 # GNU Affero General Public License version 3 (see the file LICENSE).
59
60 """Test source package diffs."""
61@@ -19,11 +19,12 @@
62 )
63 from lp.soyuz.enums import PackageDiffStatus
64 from lp.soyuz.tests.soyuz import TestPackageDiffsBase
65+from lp.testing import TestCaseWithFactory
66 from lp.testing.dbuser import dbuser
67 from lp.testing.layers import LaunchpadZopelessLayer
68
69
70-class TestPackageDiffs(TestPackageDiffsBase):
71+class TestPackageDiffs(TestPackageDiffsBase, TestCaseWithFactory):
72 """Test package diffs."""
73 layer = LaunchpadZopelessLayer
74 dbuser = config.uploader.dbuser
75@@ -100,3 +101,21 @@
76 diff.performDiff()
77 # The diff fails due to the presence of expired files.
78 self.assertEqual(PackageDiffStatus.FAILED, diff.status)
79+
80+ def test_packagediff_private_with_copied_spr(self):
81+ # If an SPR has been copied from a private archive to a public
82+ # archive, diffs against it are public.
83+ p3a = self.factory.makeArchive(private=True)
84+ orig_spr = self.factory.makeSourcePackageRelease(archive=p3a)
85+ spph = self.factory.makeSourcePackagePublishingHistory(
86+ archive=p3a, sourcepackagerelease=orig_spr)
87+ private_spr = self.factory.makeSourcePackageRelease(archive=p3a)
88+ private_diff = private_spr.requestDiffTo(p3a.owner, orig_spr)
89+ self.assertEqual(1, len(orig_spr.published_archives))
90+ self.assertTrue(private_diff.private)
91+ ppa = self.factory.makeArchive(owner=p3a.owner)
92+ spph.copyTo(spph.distroseries, spph.pocket, ppa)
93+ self.assertEqual(2, len(orig_spr.published_archives))
94+ public_spr = self.factory.makeSourcePackageRelease(archive=ppa)
95+ public_diff = public_spr.requestDiffTo(p3a.owner, orig_spr)
96+ self.assertFalse(public_diff.private)