mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 00:24:13 +00:00
Merge pull request #970 from tahoe-lafs/3590.error-in-integration-test
Fix URI redirect error that was manifesting in the integration tests Fixes ticket:3590
This commit is contained in:
commit
dc3871b711
@ -127,12 +127,12 @@ def test_deep_stats(alice):
|
||||
dircap_uri,
|
||||
data={
|
||||
u"t": u"upload",
|
||||
u"when_done": u".",
|
||||
},
|
||||
files={
|
||||
u"file": FILE_CONTENTS,
|
||||
},
|
||||
)
|
||||
resp.raise_for_status()
|
||||
|
||||
# confirm the file is in the directory
|
||||
resp = requests.get(
|
||||
|
1
newsfragments/3590.bugfix
Normal file
1
newsfragments/3590.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fixed issue where redirecting old-style URIs (/uri/?uri=...) didn't work.
|
@ -4757,6 +4757,31 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
op_url = self.webish_url + "/operations/134?t=status&output=JSON"
|
||||
yield self.assertHTTPError(op_url, 404, "unknown/expired handle '134'")
|
||||
|
||||
@inlineCallbacks
|
||||
def test_uri_redirect(self):
|
||||
"""URI redirects don't cause failure.
|
||||
|
||||
Unit test reproducer for https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3590
|
||||
"""
|
||||
def req(method, path, **kwargs):
|
||||
return treq.request(method, self.webish_url + path, persistent=False,
|
||||
**kwargs)
|
||||
|
||||
response = yield req("POST", "/uri?format=sdmf&t=mkdir")
|
||||
dircap = yield response.content()
|
||||
assert dircap.startswith('URI:DIR2:')
|
||||
dircap_uri = "/uri/?uri={}&t=json".format(urllib.quote(dircap))
|
||||
|
||||
response = yield req(
|
||||
"GET",
|
||||
dircap_uri,
|
||||
)
|
||||
self.assertEqual(
|
||||
response.request.absoluteURI,
|
||||
self.webish_url + "/uri/{}?t=json".format(urllib.quote(dircap)))
|
||||
if response.code >= 400:
|
||||
raise Error(response.code, response=response.content())
|
||||
|
||||
def test_incident(self):
|
||||
d = self.POST("/report_incident", details="eek")
|
||||
def _done(res):
|
||||
|
@ -11,7 +11,7 @@ from twisted.web import (
|
||||
resource,
|
||||
static,
|
||||
)
|
||||
from twisted.web.util import redirectTo
|
||||
from twisted.web.util import redirectTo, Redirect
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.web.template import (
|
||||
Element,
|
||||
@ -147,7 +147,7 @@ class URIHandler(resource.Resource, object):
|
||||
and creates and appropriate handler (depending on the kind of
|
||||
capability it was passed).
|
||||
"""
|
||||
# this is in case a URI like "/uri/?cap=<valid capability>" is
|
||||
# this is in case a URI like "/uri/?uri=<valid capability>" is
|
||||
# passed -- we re-direct to the non-trailing-slash version so
|
||||
# that there is just one valid URI for "uri" resource.
|
||||
if not name:
|
||||
@ -155,7 +155,7 @@ class URIHandler(resource.Resource, object):
|
||||
u = u.replace(
|
||||
path=(s for s in u.path if s), # remove empty segments
|
||||
)
|
||||
return redirectTo(u.to_uri().to_text().encode('utf8'), req)
|
||||
return Redirect(u.to_uri().to_text().encode('utf8'))
|
||||
try:
|
||||
node = self.client.create_node_from_uri(name)
|
||||
return directory.make_handler_for(node, self.client)
|
||||
|
Loading…
x
Reference in New Issue
Block a user