Merge lp:~sil2100/cupstream2distro/fix_ppa_publish into lp:cupstream2distro

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 1100
Merged at revision: 1100
Proposed branch: lp:~sil2100/cupstream2distro/fix_ppa_publish
Merge into: lp:cupstream2distro
Diff against target: 76 lines (+21/-7)
2 files modified
citrain/recipes/base.py (+2/-2)
tests/unit/test_recipe_base.py (+19/-5)
To merge this branch: bzr merge lp:~sil2100/cupstream2distro/fix_ppa_publish
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
CU2D maintainers Pending
Review via email: mp+271326@code.launchpad.net

Commit message

When checking user upload permissions, check all of it regarding the main_archive - also get the component name from the archive itself. This has some implications, since we don't check upload permissions to the dest archive but take everything through the eyes of the archive.

Description of the change

When checking user upload permissions, check all of it regarding the main_archive - also get the component name from the archive itself. This has some implications, since we don't check upload permissions to the dest archive but take everything through the eyes of the archive.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1099
http://jenkins.qa.ubuntu.com/job/cu2d-choo-choo-ci/788/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/cu2d-choo-choo-ci/788/rebuild

review: Approve (continuous-integration)
1100. By Łukasz Zemczak

Change of approach. As per Colin's recommendations, we need to check all permissions as per the main archive.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1100
http://jenkins.qa.ubuntu.com/job/cu2d-choo-choo-ci/789/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/cu2d-choo-choo-ci/789/rebuild

review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Will test that in staging tomorrow.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks correct on staging, merging ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'citrain/recipes/base.py'
2--- citrain/recipes/base.py 2015-09-14 06:52:53 +0000
3+++ citrain/recipes/base.py 2015-09-16 15:37:22 +0000
4@@ -296,7 +296,7 @@
5
6 def checkupload_phase(self):
7 """Confirm that the silo publisher has upload rights."""
8- sourcepub = self.dest.getPublishedSources(
9+ sourcepub = self.main_archive.getPublishedSources(
10 distro_series=self.series,
11 source_name=self.name,
12 status='Published',
13@@ -315,7 +315,7 @@
14 kwargs.update(
15 component=sourcepub[0].component_name,
16 sourcepackagename=self.name)
17- log_value_of.kwargs('self.dest.checkUpload')
18+ log_value_of.kwargs('self.main_archive.checkUpload')
19 try:
20 self.main_archive.checkUpload(**kwargs)
21 self.authorized = True
22
23=== modified file 'tests/unit/test_recipe_base.py'
24--- tests/unit/test_recipe_base.py 2015-09-14 06:52:53 +0000
25+++ tests/unit/test_recipe_base.py 2015-09-16 15:37:22 +0000
26@@ -428,9 +428,9 @@
27 lp_mock.people = dict(robru=robru)
28 build = BuildBase('qt', self.series, self.dest, self.ppa)
29 build.blame = robru
30- build.dest.getPublishedSources.return_value = [src]
31+ build.main_archive.getPublishedSources.return_value = [src]
32 build.checkupload_phase()
33- build.dest.getPublishedSources.assert_called_once_with(
34+ build.main_archive.getPublishedSources.assert_called_once_with(
35 distro_series=self.series,
36 status='Published',
37 pocket='Release',
38@@ -452,9 +452,9 @@
39 lp_mock.people = dict(robru=robru)
40 build = BuildBase('qt', self.series, self.dest, self.ppa)
41 build.blame = robru
42- build.dest.getPublishedSources.return_value = None
43+ build.main_archive.getPublishedSources.return_value = None
44 build.checkupload_phase()
45- build.dest.getPublishedSources.assert_called_once_with(
46+ build.main_archive.getPublishedSources.assert_called_once_with(
47 distro_series=self.series,
48 status='Published',
49 pocket='Release',
50@@ -477,11 +477,25 @@
51 lp_mock.people = dict(robru=robru)
52 build = BuildBase('qt', self.series, self.dest, self.ppa)
53 build.blame = Mock()
54- build.dest.getPublishedSources.return_value = [src]
55+ build.main_archive.getPublishedSources.return_value = [src]
56 build.main_archive.checkUpload.side_effect = ClientError(None, None)
57 build.checkupload_phase()
58 self.assertFalse(build.authorized)
59
60+ @patch('citrain.recipes.base.lp')
61+ def test_buildbase_checkupload_phase_non_archive(self, lp_mock):
62+ """Ensure that we check archive permissions, even for PPAs."""
63+ src = Mock()
64+ robru = Mock()
65+ env.BUILD_USER_ID = 'robru'
66+ lp_mock.people = dict(robru=robru)
67+ build = BuildBase('qt', self.series, self.dest, self.ppa)
68+ build.blame = Mock()
69+ build.main_archive.getPublishedSources.return_value = [src]
70+ build.dest.checkUpload.side_effect = ClientError(None, None)
71+ build.checkupload_phase()
72+ self.assertTrue(build.authorized)
73+
74 def test_buildbase_ackaging_phase_authorized_success(self):
75 """Ensure that authorized people can ACK."""
76 env.ACK_PACKAGING = 'true'

Subscribers

People subscribed via source and target branches