mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
test_web.py: add coverage for directory listings that include mutable files
This commit is contained in:
parent
785f21b9bf
commit
53e865cf49
@ -92,6 +92,8 @@ class FakeMutableFileNode:
|
||||
return defer.succeed(self.all_contents[self.storage_index])
|
||||
def get_writekey(self):
|
||||
return "\x00"*16
|
||||
def get_size(self):
|
||||
return "?" # TODO: see mutable.MutableFileNode.get_size
|
||||
|
||||
def replace(self, new_contents, wait_for_numpeers=None):
|
||||
assert not self.is_readonly()
|
||||
|
@ -941,6 +941,17 @@ class Web(WebMixin, unittest.TestCase):
|
||||
self.failUnlessEqual(self._mutable_uri, newnode.get_uri())
|
||||
d.addCallback(_got3)
|
||||
|
||||
# finally list the directory, since mutable files are displayed
|
||||
# differently
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.GET(self.public_url + "/foo",
|
||||
followRedirect=True))
|
||||
def _check_page(res):
|
||||
# TODO: assert something about the contents
|
||||
pass
|
||||
d.addCallback(_check_page)
|
||||
|
||||
return d
|
||||
|
||||
def test_POST_upload_replace(self):
|
||||
|
@ -185,28 +185,7 @@ class Directory(rend.Page):
|
||||
or IDirectoryNode.providedBy(target)
|
||||
or IMutableFileNode.providedBy(target)), target
|
||||
|
||||
if IFileNode.providedBy(target):
|
||||
# file
|
||||
|
||||
# add the filename to the uri_link url
|
||||
uri_link += '?%s' % (urllib.urlencode({'filename': name}),)
|
||||
|
||||
# to prevent javascript in displayed .html files from stealing a
|
||||
# secret directory URI from the URL, send the browser to a URI-based
|
||||
# page that doesn't know about the directory at all
|
||||
#dlurl = urllib.quote(name)
|
||||
dlurl = uri_link
|
||||
|
||||
ctx.fillSlots("filename",
|
||||
T.a(href=dlurl)[html.escape(name)])
|
||||
ctx.fillSlots("type", "FILE")
|
||||
|
||||
ctx.fillSlots("size", target.get_size())
|
||||
|
||||
text_plain_link = uri_link + "?filename=foo.txt"
|
||||
text_plain_tag = T.a(href=text_plain_link)["text/plain"]
|
||||
|
||||
elif IMutableFileNode.providedBy(target):
|
||||
if IMutableFileNode.providedBy(target):
|
||||
# file
|
||||
|
||||
# add the filename to the uri_link url
|
||||
@ -227,6 +206,26 @@ class Directory(rend.Page):
|
||||
text_plain_link = uri_link + "?filename=foo.txt"
|
||||
text_plain_tag = T.a(href=text_plain_link)["text/plain"]
|
||||
|
||||
elif IFileNode.providedBy(target):
|
||||
# file
|
||||
|
||||
# add the filename to the uri_link url
|
||||
uri_link += '?%s' % (urllib.urlencode({'filename': name}),)
|
||||
|
||||
# to prevent javascript in displayed .html files from stealing a
|
||||
# secret directory URI from the URL, send the browser to a URI-based
|
||||
# page that doesn't know about the directory at all
|
||||
#dlurl = urllib.quote(name)
|
||||
dlurl = uri_link
|
||||
|
||||
ctx.fillSlots("filename",
|
||||
T.a(href=dlurl)[html.escape(name)])
|
||||
ctx.fillSlots("type", "FILE")
|
||||
|
||||
ctx.fillSlots("size", target.get_size())
|
||||
|
||||
text_plain_link = uri_link + "?filename=foo.txt"
|
||||
text_plain_tag = T.a(href=text_plain_link)["text/plain"]
|
||||
|
||||
elif IDirectoryNode.providedBy(target):
|
||||
# directory
|
||||
|
Loading…
x
Reference in New Issue
Block a user