mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
web: make sure that PUT /uri?mutable=false really means immutable, fixes #675
This commit is contained in:
parent
4b2f6fc098
commit
922b3034be
@ -717,6 +717,17 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
|
||||
self.NEWFILE_CONTENTS))
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILEURL_not_mutable(self):
|
||||
d = self.PUT(self.public_url + "/foo/new.txt?mutable=false",
|
||||
self.NEWFILE_CONTENTS)
|
||||
# TODO: we lose the response code, so we can't check this
|
||||
#self.failUnlessEqual(responsecode, 201)
|
||||
d.addCallback(self.failUnlessURIMatchesChild, self._foo_node, u"new.txt")
|
||||
d.addCallback(lambda res:
|
||||
self.failUnlessChildContentsAre(self._foo_node, u"new.txt",
|
||||
self.NEWFILE_CONTENTS))
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILEURL_range_bad(self):
|
||||
headers = {"content-range": "bytes 1-10/%d" % len(self.NEWFILE_CONTENTS)}
|
||||
target = self.public_url + "/foo/new.txt"
|
||||
@ -2309,6 +2320,21 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
|
||||
d.addCallback(_check2)
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILE_URI_not_mutable(self):
|
||||
file_contents = "New file contents here\n"
|
||||
d = self.PUT("/uri?mutable=false", file_contents)
|
||||
def _check(uri):
|
||||
assert isinstance(uri, str), uri
|
||||
self.failUnless(uri in FakeCHKFileNode.all_contents)
|
||||
self.failUnlessEqual(FakeCHKFileNode.all_contents[uri],
|
||||
file_contents)
|
||||
return self.GET("/uri/%s" % uri)
|
||||
d.addCallback(_check)
|
||||
def _check2(res):
|
||||
self.failUnlessEqual(res, file_contents)
|
||||
d.addCallback(_check2)
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILE_URI_only_PUT(self):
|
||||
d = self.PUT("/uri?t=bogus", "")
|
||||
d.addBoth(self.shouldFail, error.Error,
|
||||
|
@ -16,7 +16,7 @@ from allmydata.interfaces import IFileNode
|
||||
from allmydata.web import filenode, directory, unlinked, status, operations
|
||||
from allmydata.web import reliability, storage
|
||||
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
|
||||
get_arg, RenderMixin
|
||||
get_arg, RenderMixin, boolean_of_arg
|
||||
|
||||
|
||||
class URIHandler(RenderMixin, rend.Page):
|
||||
@ -45,7 +45,7 @@ class URIHandler(RenderMixin, rend.Page):
|
||||
# "PUT /uri?t=mkdir" to create an unlinked directory
|
||||
t = get_arg(req, "t", "").strip()
|
||||
if t == "":
|
||||
mutable = bool(get_arg(req, "mutable", "").strip())
|
||||
mutable = boolean_of_arg(get_arg(req, "mutable", "false").strip())
|
||||
if mutable:
|
||||
return unlinked.PUTUnlinkedSSK(req, self.client)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user