Merge lp:~salgado/launchpad/bug-535021 into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/bug-535021
Merge into: lp:launchpad
Diff against target: 236 lines (+38/-23)
12 files modified
lib/canonical/launchpad/browser/tests/test_launchpad.py (+1/-1)
lib/canonical/launchpad/browser/tests/test_password_reset.py (+1/-1)
lib/lp/bugs/stories/patches-view/patches-view.txt (+4/-2)
lib/lp/code/browser/tests/test_branchmergeproposal.py (+1/-1)
lib/lp/code/stories/codeimport/xx-edit-codeimport.txt (+4/-2)
lib/lp/registry/browser/tests/person-views.txt (+3/-2)
lib/lp/registry/browser/tests/test_person_webservice.py (+5/-1)
lib/lp/registry/tests/test_personset.py (+2/-1)
lib/lp/testing/factory.py (+10/-9)
lib/lp/translations/stories/importqueue/xx-entry-details.txt (+3/-1)
lib/lp/translations/stories/standalone/custom-language-codes.txt (+2/-1)
lib/lp/translations/stories/standalone/xx-pofile-details.txt (+2/-1)
To merge this branch: bzr merge lp:~salgado/launchpad/bug-535021
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+21235@code.launchpad.net

Description of the change

Fix bug 535021 by making makePersonNoCommit() do not return a
non-security-proxied Person object.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/registry/browser/tests/person-views.txt
  lib/canonical/launchpad/browser/tests/test_password_reset.py
  lib/lp/registry/tests/test_personset.py
  lib/lp/code/browser/tests/test_branchmergeproposal.py
  lib/lp/translations/stories/standalone/xx-pofile-details.txt
  lib/lp/testing/factory.py
  lib/lp/code/stories/codeimport/xx-edit-codeimport.txt
  lib/lp/translations/stories/importqueue/xx-entry-details.txt
  lib/lp/translations/stories/standalone/custom-language-codes.txt
  lib/lp/bugs/stories/patches-view/patches-view.txt
  lib/canonical/launchpad/browser/tests/test_launchpad.py

== Pylint notices ==

lib/lp/testing/factory.py
    1708: [F0401, LaunchpadObjectFactory.makeRecipe] Unable to import 'bzrlib.plugins.builder.recipe' (No module named builder)

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) wrote :

looks good

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/browser/tests/test_launchpad.py'
2--- lib/canonical/launchpad/browser/tests/test_launchpad.py 2009-12-23 17:20:00 +0000
3+++ lib/canonical/launchpad/browser/tests/test_launchpad.py 2010-03-12 19:17:26 +0000
4@@ -152,7 +152,7 @@
5 name = 'suspended-person'
6 person = self.factory.makePerson(name=name)
7 login_person(self.admin)
8- person.account_status = AccountStatus.SUSPENDED
9+ removeSecurityProxy(person).account_status = AccountStatus.SUSPENDED
10 segment = '~%s' % name
11 # Admins can see the suspended user.
12 traversed = self.traverse(segment, segment)
13
14=== modified file 'lib/canonical/launchpad/browser/tests/test_password_reset.py'
15--- lib/canonical/launchpad/browser/tests/test_password_reset.py 2009-10-29 15:09:28 +0000
16+++ lib/canonical/launchpad/browser/tests/test_password_reset.py 2010-03-12 19:17:26 +0000
17@@ -39,7 +39,7 @@
18
19 def _create_deactivated_person(self):
20 self.person = self.factory.makePerson(email=self.email)
21- removeSecurityProxy(self.person.deactivateAccount('Testing'))
22+ removeSecurityProxy(self.person).deactivateAccount('Testing')
23 # Get the account from the master DB to make sure it has the changes
24 # we did above.
25 self.account = IMasterObject(self.person.account)
26
27=== modified file 'lib/lp/bugs/stories/patches-view/patches-view.txt'
28--- lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-18 22:10:21 +0000
29+++ lib/lp/bugs/stories/patches-view/patches-view.txt 2010-03-12 19:17:26 +0000
30@@ -371,9 +371,11 @@
31
32 The patches view works for people and teams.
33
34+ # Must remove the security proxy because IPerson.name is protected.
35+ >>> from zope.security.proxy import removeSecurityProxy
36+ >>> submitter_name = removeSecurityProxy(patch_submitter).name
37 >>> anon_browser.open(
38- ... 'http://bugs.launchpad.dev/~%s/+patches' % (
39- ... patch_submitter.name,))
40+ ... 'http://bugs.launchpad.dev/~%s/+patches' % submitter_name)
41
42 >>> show_patches_view(anon_browser.contents)
43 Bug Importance Status Project Patch Age
44
45=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
46--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2010-02-23 21:48:53 +0000
47+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2010-03-12 19:17:26 +0000
48@@ -486,7 +486,7 @@
49 """Claiming a review works for members of the requested team."""
50 review = self.makeTeamReview()
51 albert = self.factory.makePerson()
52- albert.join(review.reviewer)
53+ removeSecurityProxy(albert).join(review.reviewer)
54 login_person(albert)
55 view = create_initialized_view(self.bmp, '+index')
56 view.claim_action.success({'review_id': review.id})
57
58=== modified file 'lib/lp/code/stories/codeimport/xx-edit-codeimport.txt'
59--- lib/lp/code/stories/codeimport/xx-edit-codeimport.txt 2009-11-11 08:56:46 +0000
60+++ lib/lp/code/stories/codeimport/xx-edit-codeimport.txt 2010-03-12 19:17:26 +0000
61@@ -22,8 +22,10 @@
62 >>> hosted_branch_location = str(canonical_url(hosted_branch))
63 >>> logout()
64
65- >>> import_browser = setupBrowser(
66- ... auth='Basic %s:test' % str(registrant.preferredemail.email))
67+ # Must remove the security proxy because IEmailAddress.email is protected.
68+ >>> from zope.security.proxy import removeSecurityProxy
69+ >>> email = removeSecurityProxy(registrant.preferredemail).email
70+ >>> import_browser = setupBrowser(auth='Basic %s:test' % str(email))
71
72
73 == Import details on the branch page ==
74
75=== modified file 'lib/lp/registry/browser/tests/person-views.txt'
76--- lib/lp/registry/browser/tests/person-views.txt 2010-02-22 12:48:38 +0000
77+++ lib/lp/registry/browser/tests/person-views.txt 2010-03-12 19:17:26 +0000
78@@ -47,8 +47,9 @@
79
80 New users are on probation; the homepage content is escaped HTML.
81
82+ >>> from zope.security.proxy import removeSecurityProxy
83 >>> new_user = factory.makePerson()
84- >>> new_user.homepage_content = homepage_content
85+ >>> removeSecurityProxy(new_user).homepage_content = homepage_content
86 >>> view = create_initialized_view(new_user, '+index')
87 >>> view.is_probationary_or_invalid_user
88 True
89@@ -83,7 +84,7 @@
90
91 If the user has no homepage content, the view's value is None.
92
93- >>> new_user.homepage_content = None
94+ >>> removeSecurityProxy(new_user).homepage_content = None
95 >>> view = create_initialized_view(new_user, '+index')
96 >>> print view.homepage_content
97 None
98
99=== modified file 'lib/lp/registry/browser/tests/test_person_webservice.py'
100--- lib/lp/registry/browser/tests/test_person_webservice.py 2009-11-09 23:10:34 +0000
101+++ lib/lp/registry/browser/tests/test_person_webservice.py 2010-03-12 19:17:26 +0000
102@@ -5,6 +5,8 @@
103
104 import unittest
105
106+from zope.security.proxy import removeSecurityProxy
107+
108 from canonical.launchpad.ftests import login
109 from lp.testing import TestCaseWithFactory
110 from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller
111@@ -23,8 +25,10 @@
112 'launchpad-library', 'salgado-change-anything')
113
114 def test_GET_xhtml_representation(self):
115+ # Remove the security proxy because IPerson.name is protected.
116+ person_name = removeSecurityProxy(self.person).name
117 response = self.webservice.get(
118- '/~%s' % self.person.name, 'application/xhtml+xml')
119+ '/~%s' % person_name, 'application/xhtml+xml')
120
121 self.assertEqual(response.status, 200)
122
123
124=== modified file 'lib/lp/registry/tests/test_personset.py'
125--- lib/lp/registry/tests/test_personset.py 2009-11-12 18:31:03 +0000
126+++ lib/lp/registry/tests/test_personset.py 2010-03-12 19:17:26 +0000
127@@ -136,7 +136,8 @@
128 self.assertEqual(0, self.cur.rowcount)
129
130 def test__mergeMailingListSubscriptions_with_subscriptions(self):
131- self.from_person.mailing_list_auto_subscribe_policy = (
132+ naked_person = removeSecurityProxy(self.from_person)
133+ naked_person.mailing_list_auto_subscribe_policy = (
134 MailingListAutoSubscribePolicy.ALWAYS)
135 self.team, self.mailing_list = self.factory.makeTeamAndMailingList(
136 'test-mailinglist', 'team-owner')
137
138=== modified file 'lib/lp/testing/factory.py'
139--- lib/lp/testing/factory.py 2010-03-08 12:35:15 +0000
140+++ lib/lp/testing/factory.py 2010-03-12 19:17:26 +0000
141@@ -381,8 +381,8 @@
142 a commit, despite all changes now being available in the main
143 store.
144 """
145- person = removeSecurityProxy(person) # Need to poke person's privates
146- person._preferredemail_cached = Store.of(person).find(
147+ naked_person = removeSecurityProxy(person)
148+ naked_person._preferredemail_cached = Store.of(person).find(
149 EmailAddress, personID=person.id,
150 status=EmailAddressStatus.PREFERRED).one()
151
152@@ -423,16 +423,18 @@
153 email, rationale=PersonCreationRationale.UNKNOWN, name=name,
154 password=password, displayname=displayname,
155 hide_email_addresses=hide_email_addresses)
156- person = removeSecurityProxy(person)
157- email = removeSecurityProxy(email)
158- person._password_cleartext_cached = password
159+ naked_person = removeSecurityProxy(person)
160+ naked_person._password_cleartext_cached = password
161
162 assert person.password is not None, (
163 'Password not set. Wrong default auth Store?')
164
165 if (time_zone is not None or latitude is not None or
166 longitude is not None):
167- person.setLocation(latitude, longitude, time_zone, person)
168+ naked_person.setLocation(latitude, longitude, time_zone, person)
169+
170+ # Make sure the non-security-proxied object is not returned.
171+ del naked_person
172
173 # To make the person someone valid in Launchpad, validate the
174 # email.
175@@ -442,7 +444,7 @@
176 Account, person.accountID)
177 account.status = AccountStatus.ACTIVE
178
179- email.status = email_address_status
180+ removeSecurityProxy(email).status = email_address_status
181
182 # Ensure updated ValidPersonCache
183 flush_database_updates()
184@@ -1837,8 +1839,7 @@
185 singular = self.getUniqueString()
186 potmsgset = potemplate.createMessageSetFromText(
187 singular, plural, context, sequence)
188- naked_potmsgset = removeSecurityProxy(potmsgset)
189- naked_potmsgset.sync()
190+ removeSecurityProxy(potmsgset).sync()
191 return potmsgset
192
193 def makeTranslationMessage(self, pofile=None, potmsgset=None,
194
195=== modified file 'lib/lp/translations/stories/importqueue/xx-entry-details.txt'
196--- lib/lp/translations/stories/importqueue/xx-entry-details.txt 2010-02-10 13:04:10 +0000
197+++ lib/lp/translations/stories/importqueue/xx-entry-details.txt 2010-03-12 19:17:26 +0000
198@@ -34,7 +34,9 @@
199
200 >>> product.displayname in details_text
201 True
202- >>> uploader.displayname in details_text
203+
204+ # Must remove the security proxy because IPerson.displayname is protected.
205+ >>> removeSecurityProxy(uploader).displayname in details_text
206 True
207
208 There's also a link to the file's contents.
209
210=== modified file 'lib/lp/translations/stories/standalone/custom-language-codes.txt'
211--- lib/lp/translations/stories/standalone/custom-language-codes.txt 2009-11-06 16:59:34 +0000
212+++ lib/lp/translations/stories/standalone/custom-language-codes.txt 2010-03-12 19:17:26 +0000
213@@ -25,7 +25,8 @@
214 >>> owner = factory.makePerson(email='o@example.com', password='test')
215 >>> rosetta_admin = factory.makePerson(
216 ... email='r@example.com', password='test')
217- >>> rosetta_admin.join(getUtility(ILaunchpadCelebrities).rosetta_experts)
218+ >>> removeSecurityProxy(rosetta_admin).join(
219+ ... getUtility(ILaunchpadCelebrities).rosetta_experts)
220 >>> product = factory.makeProduct(displayname="Foo", owner=owner)
221 >>> trunk = product.getSeries('trunk')
222 >>> removeSecurityProxy(product).official_rosetta = True
223
224=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-details.txt'
225--- lib/lp/translations/stories/standalone/xx-pofile-details.txt 2009-12-15 14:11:39 +0000
226+++ lib/lp/translations/stories/standalone/xx-pofile-details.txt 2010-03-12 19:17:26 +0000
227@@ -157,7 +157,8 @@
228 >>> potmsgset.setSequence(template, 2)
229 >>> translation = factory.makeTranslationMessage(pofile=pofile,
230 ... translator=translator, potmsgset=potmsgset)
231- >>> merged_translator.merged = translator
232+ >>> from zope.security.proxy import removeSecurityProxy
233+ >>> removeSecurityProxy(merged_translator).merged = translator
234 >>> logout()
235
236 >>> browser.open(