Merge ~cjwatson/launchpad:remove-98437-workarounds into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 74c15f62b6b744f4728535128cb43a94905e8d58
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-98437-workarounds
Merge into: launchpad:master
Diff against target: 187 lines (+22/-76)
7 files modified
lib/lp/app/stories/basics/notfound-error.txt (+15/-18)
lib/lp/bugs/browser/bugsubscription.py (+4/-7)
lib/lp/bugs/browser/bugtask.py (+2/-8)
lib/lp/services/webapp/publication.py (+0/-8)
lib/lp/services/webapp/tests/test_publication.py (+0/-8)
lib/lp/testing/browser.py (+1/-24)
lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt (+0/-3)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+374726@code.launchpad.net

Commit message

Remove workarounds for bug 98437, fixed in Zope

Description of the change

We've had sufficient versions of zope.app.testing and zope.testbrowser for a while.

To post a comment you must log in.
6a577ca... by Colin Watson

Remove unused import

Revision history for this message
Tom Wardill (twom) wrote :

Removal of workaround code, double yay!

review: Approve
74c15f6... by Colin Watson

Remove TestBlockingOffsitePosts.test_localhost_is_ok

This is no longer expected to pass, as we removed the corresponding
workaround.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/stories/basics/notfound-error.txt b/lib/lp/app/stories/basics/notfound-error.txt
2index ba3a48a..f6b0d75 100644
3--- a/lib/lp/app/stories/basics/notfound-error.txt
4+++ b/lib/lp/app/stories/basics/notfound-error.txt
5@@ -29,22 +29,19 @@ It also contains instructions specific to broken links.
6 If you go to a non-existent page directly, without sending a Referer:
7 header, the 404 page does not try to link to the referring page.
8 And the advice about broken links is gone, replaced with advice about
9-mistyped URLs.
10+things like mistyped URLs.
11
12-XXX 20080114 mpt: At the time of writing, this test passed if
13-'"HTTP_REFERER": self.host_and_port,' was commented out of
14-sourcecode/zope/src/zope/app/testing/functional.py. The test is
15-disabled until bug 98437 is fixed.
16-
17- # >>> page_with_no_referer = str(http(r"""
18- # ... GET /+fhqwhgads HTTP/1.1
19- # ... """))
20- # >>> print page_with_no_referer
21- # HTTP/1.1 404 Not Found
22- # ...
23- # >>> main_content = find_main_content(page_with_no_referer)
24- # >>> for paragraph in main_content('p'):
25- # ... print extract_text(paragraph)
26- # There’s no page with this address in Launchpad.
27- # Check that you entered the address correctly.
28- # ...
29+ >>> page_with_no_referer = str(http(r"""
30+ ... GET /+fhqwhgads HTTP/1.1
31+ ... """))
32+ >>> print page_with_no_referer
33+ HTTP/1.1 404 Not Found
34+ ...
35+ >>> main_content = find_main_content(page_with_no_referer)
36+ >>> for paragraph in main_content('p'):
37+ ... print extract_text(paragraph)
38+ This page does not exist, or you may not have permission to see it.
39+ If you have been to this page before, it is possible it has been removed.
40+ Check that you are logged in with the correct account, or that you
41+ entered the address correctly, or search for it:
42+ ...
43diff --git a/lib/lp/bugs/browser/bugsubscription.py b/lib/lp/bugs/browser/bugsubscription.py
44index 544ae49..b8a689e 100644
45--- a/lib/lp/bugs/browser/bugsubscription.py
46+++ b/lib/lp/bugs/browser/bugsubscription.py
47@@ -181,13 +181,10 @@ class BugSubscriptionSubscribeSelfView(LaunchpadFormView,
48 referer = self._return_url
49 context_url = canonical_url(self.context)
50
51- # XXX bdmurray 2010-09-30 bug=98437: work around zope's test
52- # browser setting referer to localhost.
53- # We also ignore the current request URL and the context URL as
54- # far as referrers are concerned so that we can handle privacy
55- # issues properly.
56- ignored_referrer_urls = (
57- 'localhost', self.request.getURL(), context_url)
58+ # Ignore the current request URL and the context URL as far as
59+ # referrers are concerned so that we can handle privacy issues
60+ # properly.
61+ ignored_referrer_urls = (self.request.getURL(), context_url)
62 if referer and referer not in ignored_referrer_urls:
63 next_url = referer
64 elif self._redirecting_to_bug_list:
65diff --git a/lib/lp/bugs/browser/bugtask.py b/lib/lp/bugs/browser/bugtask.py
66index 0b9ec84..b25e213 100644
67--- a/lib/lp/bugs/browser/bugtask.py
68+++ b/lib/lp/bugs/browser/bugtask.py
69@@ -464,10 +464,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
70 def next_url(self):
71 """Provided so returning to the page they came from works."""
72 referer = self.request.getHeader('referer')
73-
74- # XXX bdmurray 2010-09-30 bug=98437: work around zope's test
75- # browser setting referer to localhost.
76- if referer and referer != 'localhost':
77+ if referer:
78 next_url = referer
79 else:
80 next_url = canonical_url(self.context)
81@@ -477,10 +474,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
82 def cancel_url(self):
83 """Provided so returning to the page they came from works."""
84 referer = self.request.getHeader('referer')
85-
86- # XXX bdmurray 2010-09-30 bug=98437: work around zope's test
87- # browser setting referer to localhost.
88- if referer and referer != 'localhost':
89+ if referer:
90 cancel_url = referer
91 else:
92 cancel_url = canonical_url(self.context)
93diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
94index ece870a..716dd2e 100644
95--- a/lib/lp/services/webapp/publication.py
96+++ b/lib/lp/services/webapp/publication.py
97@@ -153,14 +153,6 @@ def maybe_block_offsite_form_post(request):
98 referrer = request.getHeader('referer') # Match HTTP spec misspelling.
99 if not referrer:
100 raise NoReferrerError('No value for REFERER header')
101- # XXX: jamesh 2007-04-26 bug=98437:
102- # The Zope testing infrastructure sets a default (incorrect)
103- # referrer value of "localhost" or "localhost:9000" if no
104- # referrer is included in the request. We let it pass through
105- # here for the benefits of the tests. Web browsers send full
106- # URLs so this does not open us up to extra XSRF attacks.
107- if referrer in ['localhost', 'localhost:9000']:
108- return
109 # Extract the hostname from the referrer URI
110 try:
111 hostname = URI(referrer).host
112diff --git a/lib/lp/services/webapp/tests/test_publication.py b/lib/lp/services/webapp/tests/test_publication.py
113index 76253da..335f999 100644
114--- a/lib/lp/services/webapp/tests/test_publication.py
115+++ b/lib/lp/services/webapp/tests/test_publication.py
116@@ -203,14 +203,6 @@ class TestBlockingOffsitePosts(TestCase):
117 request = LaunchpadTestRequest(method='SOMETHING')
118 maybe_block_offsite_form_post(request)
119
120- def test_localhost_is_ok(self):
121- # we accept "localhost" and "localhost:9000" as valid referrers. See
122- # comments in the code as to why and for a related bug report.
123- request = LaunchpadTestRequest(
124- method='POST', environ=dict(PATH_INFO='/', REFERER='localhost'))
125- # this doesn't raise an exception
126- maybe_block_offsite_form_post(request)
127-
128 def test_whitelisted_paths(self):
129 # There are a few whitelisted POST targets that don't require the
130 # referrer be LP. See comments in the code as to why and for related
131diff --git a/lib/lp/testing/browser.py b/lib/lp/testing/browser.py
132index e858d95..9df40df 100644
133--- a/lib/lp/testing/browser.py
134+++ b/lib/lp/testing/browser.py
135@@ -30,10 +30,7 @@ import urllib2
136 import weakref
137
138 import transaction
139-from zope.testbrowser.browser import (
140- Browser as _Browser,
141- fix_exception_name,
142- )
143+from zope.testbrowser.browser import Browser as _Browser
144
145 from lp.testing.pages import (
146 extract_text,
147@@ -103,26 +100,6 @@ class Browser(_Browser):
148 super(Browser, self)._changed()
149 transaction.commit()
150
151- def _clickSubmit(self, form, control, coord):
152- # XXX gary 2010-03-08 bug=98437
153- # This change is taken from
154- # https://bugs.launchpad.net/zope3/+bug/98437/comments/9 . It
155- # should be pushed upstream, per that comment.
156- labels = control.get_labels()
157- if labels:
158- label = labels[0].text
159- else:
160- label = None
161- self.mech_browser.form = form
162- self._start_timer()
163- try:
164- self.mech_browser.submit(id=control.id, name=control.name,
165- label=label, coord=coord)
166- except Exception as e:
167- fix_exception_name(e)
168- raise
169- self._stop_timer()
170-
171 @property
172 def vhost(self):
173 uri = URI(self.url)
174diff --git a/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt b/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
175index 3d70b1d..0076838 100644
176--- a/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
177+++ b/lib/lp/translations/stories/importqueue/xx-translation-import-queue-entry.txt
178@@ -7,9 +7,6 @@ Submission and cancellation links
179 If we load an import queue entry directly from the global import queue and
180 approve it, we end up back on the global translations import queue.
181
182-XXX DaniloSegan 2009-09-01: due to Zope bug #98437 we can't test that
183-this works properly when no "referer" header is sent.
184-
185 >>> admin_browser.open('http://translations.launchpad.test/+imports')
186 >>> admin_browser.getLink(url='imports/1').click()
187 >>> print(admin_browser.getLink('Cancel').url)

Subscribers

People subscribed via source and target branches

to status/vote changes: