d.addBoth(self.should404, "test_GET_FILEURL_uri_missing")
return d
+ def _check_upload_and_mkdir_forms(self, html):
+ # We should have a form to create a file, with radio buttons that allow
+ # the user to toggle whether it is a CHK/LIT (default), SDMF, or MDMF file.
+ self.failUnlessIn('name="t" value="upload"', html)
+ self.failUnlessIn('input checked="checked" type="radio" id="upload-chk" value="chk" name="format"', html)
+ self.failUnlessIn('input type="radio" id="upload-sdmf" value="sdmf" name="format"', html)
+ self.failUnlessIn('input type="radio" id="upload-mdmf" value="mdmf" name="format"', html)
+
+ # We should also have the ability to create a mutable directory, with
+ # radio buttons that allow the user to toggle whether it is an SDMF (default)
+ # or MDMF directory.
+ self.failUnlessIn('name="t" value="mkdir"', html)
+ self.failUnlessIn('input checked="checked" type="radio" id="mkdir-sdmf" value="sdmf" name="format"', html)
+ self.failUnlessIn('input type="radio" id="mkdir-mdmf" value="mdmf" name="format"', html)
+
def test_GET_DIRECTORY_html(self):
d = self.GET(self.public_url + "/foo", followRedirect=True)
- def _check(res):
- self.failUnlessIn('<div class="toolbar-item"><a href="../../..">Return to Welcome page</a></div>',res)
- # These are radio buttons that allow a user to toggle
- # whether a particular mutable file is SDMF or MDMF.
- self.failUnlessIn("mutable-type-mdmf", res)
- self.failUnlessIn("mutable-type-sdmf", res)
- # Similarly, these toggle whether a particular directory
- # should be MDMF or SDMF.
- self.failUnlessIn("mutable-directory-mdmf", res)
- self.failUnlessIn("mutable-directory-sdmf", res)
- self.failUnlessIn("quux", res)
+ def _check(html):
+ self.failUnlessIn('<div class="toolbar-item"><a href="../../..">Return to Welcome page</a></div>', html)
+ self._check_upload_and_mkdir_forms(html)
+ self.failUnlessIn("quux", html)
d.addCallback(_check)
return d
def test_GET_root_html(self):
- # make sure that we have the option to upload an unlinked
- # mutable file in SDMF and MDMF formats.
- d = self.GET("/")
- def _got_html(html):
- # These are radio buttons that allow the user to toggle
- # whether a particular mutable file is MDMF or SDMF.
- self.failUnlessIn("mutable-type-mdmf", html)
- self.failUnlessIn("mutable-type-sdmf", html)
- # We should also have the ability to create a mutable directory.
- self.failUnlessIn("mkdir", html)
- # ...and we should have the ability to say whether that's an
- # MDMF or SDMF directory
- self.failUnlessIn("mutable-directory-mdmf", html)
- self.failUnlessIn("mutable-directory-sdmf", html)
- d.addCallback(_got_html)
- return d
-
- def test_mutable_type_defaults(self):
- # The checked="checked" attribute of the inputs corresponding to
- # the mutable-type parameter should change as expected with the
- # value configured in tahoe.cfg.
- #
- # By default, the value configured with the client is
- # SDMF_VERSION, so that should be checked.
- assert self.s.mutable_file_default == SDMF_VERSION
-
d = self.GET("/")
- def _got_html(html, value):
- i = 'input checked="checked" type="radio" id="mutable-type-%s"'
- self.failUnlessIn(i % value, html)
- d.addCallback(_got_html, "sdmf")
- d.addCallback(lambda ignored:
- self.GET(self.public_url + "/foo", followRedirect=True))
- d.addCallback(_got_html, "sdmf")
- # Now switch the configuration value to MDMF. The MDMF radio
- # buttons should now be checked on these pages.
- def _swap_values(ignored):
- self.s.mutable_file_default = MDMF_VERSION
- d.addCallback(_swap_values)
- d.addCallback(lambda ignored: self.GET("/"))
- d.addCallback(_got_html, "mdmf")
- d.addCallback(lambda ignored:
- self.GET(self.public_url + "/foo", followRedirect=True))
- d.addCallback(_got_html, "mdmf")
+ d.addCallback(self._check_upload_and_mkdir_forms)
return d
def test_GET_DIRURL(self):
def test_POST_NEWDIRURL_emptyname(self):
# an empty pathname component (i.e. a double-slash) is disallowed
- d = self.shouldFail2(error.Error, "test_POST_NEWDIRURL_emptyname",
+ d = self.shouldFail2(error.Error, "POST_NEWDIRURL_emptyname",
"400 Bad Request",
"The webapi does not allow empty pathname components, i.e. a double slash",
self.POST, self.public_url + "//?t=mkdir")
def test_POST_mkdir_immutable_bad(self):
(newkids, caps) = self._create_initial_children()
- d = self.shouldFail2(error.Error, "test_POST_mkdir_immutable_bad",
+ d = self.shouldFail2(error.Error, "POST_mkdir_immutable_bad",
"400 Bad Request",
"needed to be immutable but was not",
self.POST2,
# the regular /uri?t=mkdir operation is specified to ignore its body.
# Only t=mkdir-with-children pays attention to it.
(newkids, caps) = self._create_initial_children()
- d = self.shouldHTTPError("POST t=mkdir unexpected children",
+ d = self.shouldHTTPError("POST_mkdir_no_parentdir_unexpected_children",
400, "Bad Request",
"t=mkdir does not accept children=, "
"try t=mkdir-with-children instead",
return d
def test_POST_noparent_bad(self):
- d = self.shouldHTTPError("POST /uri?t=bogus", 400, "Bad Request",
+ d = self.shouldHTTPError("POST_noparent_bad",
+ 400, "Bad Request",
"/uri accepts only PUT, PUT?t=mkdir, "
"POST?t=upload, and POST?t=mkdir",
self.POST, "/uri?t=bogus")
return d
def test_POST_bad_t(self):
- d = self.shouldFail2(error.Error, "POST_bad_t", "400 Bad Request",
+ d = self.shouldFail2(error.Error, "POST_bad_t",
+ "400 Bad Request",
"POST to a directory with bad t=BOGUS",
self.POST, self.public_url + "/foo", t="BOGUS")
return d
def test_PUT_DIRURL_bad_t(self):
d = self.shouldFail2(error.Error, "test_PUT_DIRURL_bad_t",
- "400 Bad Request", "PUT to a directory",
- self.PUT, self.public_url + "/foo?t=BOGUS", "")
+ "400 Bad Request", "PUT to a directory",
+ self.PUT, self.public_url + "/foo?t=BOGUS", "")
d.addCallback(lambda res:
self.failUnlessRWChildURIIs(self.public_root,
u"foo",
def test_PUT_NEWFILEURL_uri_no_replace(self):
contents, n, new_uri = self.makefile(8)
d = self.PUT(self.public_url + "/foo/bar.txt?t=uri&replace=false", new_uri)
- d.addBoth(self.shouldFail, error.Error, "PUT_NEWFILEURL_uri_no_replace",
+ d.addBoth(self.shouldFail, error.Error,
+ "PUT_NEWFILEURL_uri_no_replace",
"409 Conflict",
"There was already a child by that name, and you asked me "
"to not replace it")
d.addCallback(_then)
# Negative offsets should cause an error.
d.addCallback(lambda ignored:
- self.shouldHTTPError("test mutable invalid offset negative",
+ self.shouldHTTPError("PUT_update_at_invalid_offset",
400, "Bad Request",
"Invalid offset",
self.PUT,
self.filecap = filecap
d.addCallback(_then)
d.addCallback(lambda ignored:
- self.shouldHTTPError("test immutable update",
+ self.shouldHTTPError("PUT_update_at_offset_immutable",
400, "Bad Request",
"immutable",
self.PUT,
def test_bad_method(self):
url = self.webish_url + self.public_url + "/foo/bar.txt"
- d = self.shouldHTTPError("test_bad_method",
+ d = self.shouldHTTPError("bad_method",
501, "Not Implemented",
"I don't know how to treat a BOGUS request.",
client.getPage, url, method="BOGUS")
def test_short_url(self):
url = self.webish_url + "/uri"
- d = self.shouldHTTPError("test_short_url", 501, "Not Implemented",
+ d = self.shouldHTTPError("short_url", 501, "Not Implemented",
"I don't know how to treat a DELETE request.",
client.getPage, url, method="DELETE")
return d
def test_ophandle_bad(self):
url = self.webish_url + "/operations/bogus?t=status"
- d = self.shouldHTTPError("test_ophandle_bad", 404, "404 Not Found",
+ d = self.shouldHTTPError("ophandle_bad", 404, "404 Not Found",
"unknown/expired handle 'bogus'",
client.getPage, url)
return d
return d
d.addCallback(_check1)
d.addCallback(lambda ignored:
- self.shouldHTTPError("test_ophandle_cancel",
+ self.shouldHTTPError("ophandle_cancel",
404, "404 Not Found",
"unknown/expired handle '128'",
self.GET,
d.addCallback(lambda ign:
self.clock.advance(2.0))
d.addCallback(lambda ignored:
- self.shouldHTTPError("test_ophandle_retainfor",
+ self.shouldHTTPError("ophandle_retainfor",
404, "404 Not Found",
"unknown/expired handle '129'",
self.GET,
self.GET("/operations/130?t=status&output=JSON&release-after-complete=true"))
# the release-after-complete=true will cause the handle to be expired
d.addCallback(lambda ignored:
- self.shouldHTTPError("test_ophandle_release_after_complete",
+ self.shouldHTTPError("ophandle_release_after_complete",
404, "404 Not Found",
"unknown/expired handle '130'",
self.GET,
d.addCallback(lambda ign:
self.clock.advance(96*60*60))
d.addCallback(lambda ign:
- self.shouldHTTPError("test_uncollected_ophandle_expired_after_100_hours",
+ self.shouldHTTPError("uncollected_ophandle_expired_after_100_hours",
404, "404 Not Found",
"unknown/expired handle '132'",
self.GET,
d.addCallback(lambda ign:
self.clock.advance(24*60*60))
d.addCallback(lambda ign:
- self.shouldHTTPError("test_collected_ophandle_expired_after_1000_minutes",
+ self.shouldHTTPError("collected_ophandle_expired_after_1_day",
404, "404 Not Found",
"unknown/expired handle '134'",
self.GET,