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"
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,
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):
# "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: