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
=== modified file 'lib/canonical/launchpad/browser/tests/test_launchpad.py'
--- lib/canonical/launchpad/browser/tests/test_launchpad.py 2009-12-23 17:20:00 +0000
+++ lib/canonical/launchpad/browser/tests/test_launchpad.py 2010-03-12 19:17:26 +0000
@@ -152,7 +152,7 @@
152 name = 'suspended-person'152 name = 'suspended-person'
153 person = self.factory.makePerson(name=name)153 person = self.factory.makePerson(name=name)
154 login_person(self.admin)154 login_person(self.admin)
155 person.account_status = AccountStatus.SUSPENDED155 removeSecurityProxy(person).account_status = AccountStatus.SUSPENDED
156 segment = '~%s' % name156 segment = '~%s' % name
157 # Admins can see the suspended user.157 # Admins can see the suspended user.
158 traversed = self.traverse(segment, segment)158 traversed = self.traverse(segment, segment)
159159
=== modified file 'lib/canonical/launchpad/browser/tests/test_password_reset.py'
--- lib/canonical/launchpad/browser/tests/test_password_reset.py 2009-10-29 15:09:28 +0000
+++ lib/canonical/launchpad/browser/tests/test_password_reset.py 2010-03-12 19:17:26 +0000
@@ -39,7 +39,7 @@
3939
40 def _create_deactivated_person(self):40 def _create_deactivated_person(self):
41 self.person = self.factory.makePerson(email=self.email)41 self.person = self.factory.makePerson(email=self.email)
42 removeSecurityProxy(self.person.deactivateAccount('Testing'))42 removeSecurityProxy(self.person).deactivateAccount('Testing')
43 # Get the account from the master DB to make sure it has the changes43 # Get the account from the master DB to make sure it has the changes
44 # we did above.44 # we did above.
45 self.account = IMasterObject(self.person.account)45 self.account = IMasterObject(self.person.account)
4646
=== modified file 'lib/lp/bugs/stories/patches-view/patches-view.txt'
--- lib/lp/bugs/stories/patches-view/patches-view.txt 2010-02-18 22:10:21 +0000
+++ lib/lp/bugs/stories/patches-view/patches-view.txt 2010-03-12 19:17:26 +0000
@@ -371,9 +371,11 @@
371371
372The patches view works for people and teams.372The patches view works for people and teams.
373373
374 # Must remove the security proxy because IPerson.name is protected.
375 >>> from zope.security.proxy import removeSecurityProxy
376 >>> submitter_name = removeSecurityProxy(patch_submitter).name
374 >>> anon_browser.open(377 >>> anon_browser.open(
375 ... 'http://bugs.launchpad.dev/~%s/+patches' % (378 ... 'http://bugs.launchpad.dev/~%s/+patches' % submitter_name)
376 ... patch_submitter.name,))
377379
378 >>> show_patches_view(anon_browser.contents)380 >>> show_patches_view(anon_browser.contents)
379 Bug Importance Status Project Patch Age381 Bug Importance Status Project Patch Age
380382
=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2010-02-23 21:48:53 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2010-03-12 19:17:26 +0000
@@ -486,7 +486,7 @@
486 """Claiming a review works for members of the requested team."""486 """Claiming a review works for members of the requested team."""
487 review = self.makeTeamReview()487 review = self.makeTeamReview()
488 albert = self.factory.makePerson()488 albert = self.factory.makePerson()
489 albert.join(review.reviewer)489 removeSecurityProxy(albert).join(review.reviewer)
490 login_person(albert)490 login_person(albert)
491 view = create_initialized_view(self.bmp, '+index')491 view = create_initialized_view(self.bmp, '+index')
492 view.claim_action.success({'review_id': review.id})492 view.claim_action.success({'review_id': review.id})
493493
=== modified file 'lib/lp/code/stories/codeimport/xx-edit-codeimport.txt'
--- lib/lp/code/stories/codeimport/xx-edit-codeimport.txt 2009-11-11 08:56:46 +0000
+++ lib/lp/code/stories/codeimport/xx-edit-codeimport.txt 2010-03-12 19:17:26 +0000
@@ -22,8 +22,10 @@
22 >>> hosted_branch_location = str(canonical_url(hosted_branch))22 >>> hosted_branch_location = str(canonical_url(hosted_branch))
23 >>> logout()23 >>> logout()
2424
25 >>> import_browser = setupBrowser(25 # Must remove the security proxy because IEmailAddress.email is protected.
26 ... auth='Basic %s:test' % str(registrant.preferredemail.email))26 >>> from zope.security.proxy import removeSecurityProxy
27 >>> email = removeSecurityProxy(registrant.preferredemail).email
28 >>> import_browser = setupBrowser(auth='Basic %s:test' % str(email))
2729
2830
29== Import details on the branch page ==31== Import details on the branch page ==
3032
=== modified file 'lib/lp/registry/browser/tests/person-views.txt'
--- lib/lp/registry/browser/tests/person-views.txt 2010-02-22 12:48:38 +0000
+++ lib/lp/registry/browser/tests/person-views.txt 2010-03-12 19:17:26 +0000
@@ -47,8 +47,9 @@
4747
48New users are on probation; the homepage content is escaped HTML.48New users are on probation; the homepage content is escaped HTML.
4949
50 >>> from zope.security.proxy import removeSecurityProxy
50 >>> new_user = factory.makePerson()51 >>> new_user = factory.makePerson()
51 >>> new_user.homepage_content = homepage_content52 >>> removeSecurityProxy(new_user).homepage_content = homepage_content
52 >>> view = create_initialized_view(new_user, '+index')53 >>> view = create_initialized_view(new_user, '+index')
53 >>> view.is_probationary_or_invalid_user54 >>> view.is_probationary_or_invalid_user
54 True55 True
@@ -83,7 +84,7 @@
8384
84If the user has no homepage content, the view's value is None.85If the user has no homepage content, the view's value is None.
8586
86 >>> new_user.homepage_content = None87 >>> removeSecurityProxy(new_user).homepage_content = None
87 >>> view = create_initialized_view(new_user, '+index')88 >>> view = create_initialized_view(new_user, '+index')
88 >>> print view.homepage_content89 >>> print view.homepage_content
89 None90 None
9091
=== modified file 'lib/lp/registry/browser/tests/test_person_webservice.py'
--- lib/lp/registry/browser/tests/test_person_webservice.py 2009-11-09 23:10:34 +0000
+++ lib/lp/registry/browser/tests/test_person_webservice.py 2010-03-12 19:17:26 +0000
@@ -5,6 +5,8 @@
55
6import unittest6import unittest
77
8from zope.security.proxy import removeSecurityProxy
9
8from canonical.launchpad.ftests import login10from canonical.launchpad.ftests import login
9from lp.testing import TestCaseWithFactory11from lp.testing import TestCaseWithFactory
10from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller12from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller
@@ -23,8 +25,10 @@
23 'launchpad-library', 'salgado-change-anything')25 'launchpad-library', 'salgado-change-anything')
2426
25 def test_GET_xhtml_representation(self):27 def test_GET_xhtml_representation(self):
28 # Remove the security proxy because IPerson.name is protected.
29 person_name = removeSecurityProxy(self.person).name
26 response = self.webservice.get(30 response = self.webservice.get(
27 '/~%s' % self.person.name, 'application/xhtml+xml')31 '/~%s' % person_name, 'application/xhtml+xml')
2832
29 self.assertEqual(response.status, 200)33 self.assertEqual(response.status, 200)
3034
3135
=== modified file 'lib/lp/registry/tests/test_personset.py'
--- lib/lp/registry/tests/test_personset.py 2009-11-12 18:31:03 +0000
+++ lib/lp/registry/tests/test_personset.py 2010-03-12 19:17:26 +0000
@@ -136,7 +136,8 @@
136 self.assertEqual(0, self.cur.rowcount)136 self.assertEqual(0, self.cur.rowcount)
137137
138 def test__mergeMailingListSubscriptions_with_subscriptions(self):138 def test__mergeMailingListSubscriptions_with_subscriptions(self):
139 self.from_person.mailing_list_auto_subscribe_policy = (139 naked_person = removeSecurityProxy(self.from_person)
140 naked_person.mailing_list_auto_subscribe_policy = (
140 MailingListAutoSubscribePolicy.ALWAYS)141 MailingListAutoSubscribePolicy.ALWAYS)
141 self.team, self.mailing_list = self.factory.makeTeamAndMailingList(142 self.team, self.mailing_list = self.factory.makeTeamAndMailingList(
142 'test-mailinglist', 'team-owner')143 'test-mailinglist', 'team-owner')
143144
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-03-08 12:35:15 +0000
+++ lib/lp/testing/factory.py 2010-03-12 19:17:26 +0000
@@ -381,8 +381,8 @@
381 a commit, despite all changes now being available in the main381 a commit, despite all changes now being available in the main
382 store.382 store.
383 """383 """
384 person = removeSecurityProxy(person) # Need to poke person's privates384 naked_person = removeSecurityProxy(person)
385 person._preferredemail_cached = Store.of(person).find(385 naked_person._preferredemail_cached = Store.of(person).find(
386 EmailAddress, personID=person.id,386 EmailAddress, personID=person.id,
387 status=EmailAddressStatus.PREFERRED).one()387 status=EmailAddressStatus.PREFERRED).one()
388388
@@ -423,16 +423,18 @@
423 email, rationale=PersonCreationRationale.UNKNOWN, name=name,423 email, rationale=PersonCreationRationale.UNKNOWN, name=name,
424 password=password, displayname=displayname,424 password=password, displayname=displayname,
425 hide_email_addresses=hide_email_addresses)425 hide_email_addresses=hide_email_addresses)
426 person = removeSecurityProxy(person)426 naked_person = removeSecurityProxy(person)
427 email = removeSecurityProxy(email)427 naked_person._password_cleartext_cached = password
428 person._password_cleartext_cached = password
429428
430 assert person.password is not None, (429 assert person.password is not None, (
431 'Password not set. Wrong default auth Store?')430 'Password not set. Wrong default auth Store?')
432431
433 if (time_zone is not None or latitude is not None or432 if (time_zone is not None or latitude is not None or
434 longitude is not None):433 longitude is not None):
435 person.setLocation(latitude, longitude, time_zone, person)434 naked_person.setLocation(latitude, longitude, time_zone, person)
435
436 # Make sure the non-security-proxied object is not returned.
437 del naked_person
436438
437 # To make the person someone valid in Launchpad, validate the439 # To make the person someone valid in Launchpad, validate the
438 # email.440 # email.
@@ -442,7 +444,7 @@
442 Account, person.accountID)444 Account, person.accountID)
443 account.status = AccountStatus.ACTIVE445 account.status = AccountStatus.ACTIVE
444446
445 email.status = email_address_status447 removeSecurityProxy(email).status = email_address_status
446448
447 # Ensure updated ValidPersonCache449 # Ensure updated ValidPersonCache
448 flush_database_updates()450 flush_database_updates()
@@ -1837,8 +1839,7 @@
1837 singular = self.getUniqueString()1839 singular = self.getUniqueString()
1838 potmsgset = potemplate.createMessageSetFromText(1840 potmsgset = potemplate.createMessageSetFromText(
1839 singular, plural, context, sequence)1841 singular, plural, context, sequence)
1840 naked_potmsgset = removeSecurityProxy(potmsgset)1842 removeSecurityProxy(potmsgset).sync()
1841 naked_potmsgset.sync()
1842 return potmsgset1843 return potmsgset
18431844
1844 def makeTranslationMessage(self, pofile=None, potmsgset=None,1845 def makeTranslationMessage(self, pofile=None, potmsgset=None,
18451846
=== modified file 'lib/lp/translations/stories/importqueue/xx-entry-details.txt'
--- lib/lp/translations/stories/importqueue/xx-entry-details.txt 2010-02-10 13:04:10 +0000
+++ lib/lp/translations/stories/importqueue/xx-entry-details.txt 2010-03-12 19:17:26 +0000
@@ -34,7 +34,9 @@
3434
35 >>> product.displayname in details_text35 >>> product.displayname in details_text
36 True36 True
37 >>> uploader.displayname in details_text37
38 # Must remove the security proxy because IPerson.displayname is protected.
39 >>> removeSecurityProxy(uploader).displayname in details_text
38 True40 True
3941
40There's also a link to the file's contents.42There's also a link to the file's contents.
4143
=== modified file 'lib/lp/translations/stories/standalone/custom-language-codes.txt'
--- lib/lp/translations/stories/standalone/custom-language-codes.txt 2009-11-06 16:59:34 +0000
+++ lib/lp/translations/stories/standalone/custom-language-codes.txt 2010-03-12 19:17:26 +0000
@@ -25,7 +25,8 @@
25 >>> owner = factory.makePerson(email='o@example.com', password='test')25 >>> owner = factory.makePerson(email='o@example.com', password='test')
26 >>> rosetta_admin = factory.makePerson(26 >>> rosetta_admin = factory.makePerson(
27 ... email='r@example.com', password='test')27 ... email='r@example.com', password='test')
28 >>> rosetta_admin.join(getUtility(ILaunchpadCelebrities).rosetta_experts)28 >>> removeSecurityProxy(rosetta_admin).join(
29 ... getUtility(ILaunchpadCelebrities).rosetta_experts)
29 >>> product = factory.makeProduct(displayname="Foo", owner=owner)30 >>> product = factory.makeProduct(displayname="Foo", owner=owner)
30 >>> trunk = product.getSeries('trunk')31 >>> trunk = product.getSeries('trunk')
31 >>> removeSecurityProxy(product).official_rosetta = True32 >>> removeSecurityProxy(product).official_rosetta = True
3233
=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-details.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-details.txt 2009-12-15 14:11:39 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-details.txt 2010-03-12 19:17:26 +0000
@@ -157,7 +157,8 @@
157 >>> potmsgset.setSequence(template, 2)157 >>> potmsgset.setSequence(template, 2)
158 >>> translation = factory.makeTranslationMessage(pofile=pofile,158 >>> translation = factory.makeTranslationMessage(pofile=pofile,
159 ... translator=translator, potmsgset=potmsgset)159 ... translator=translator, potmsgset=potmsgset)
160 >>> merged_translator.merged = translator160 >>> from zope.security.proxy import removeSecurityProxy
161 >>> removeSecurityProxy(merged_translator).merged = translator
161 >>> logout()162 >>> logout()
162163
163 >>> browser.open(164 >>> browser.open(