mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
test_web/test_system: improve test coverage
This commit is contained in:
parent
506ce2dfd0
commit
88457fbc32
@ -137,6 +137,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin,
|
|||||||
# client[0] runs a webserver and a helper, no key_generator
|
# client[0] runs a webserver and a helper, no key_generator
|
||||||
open(os.path.join(basedir, "webport"), "w").write("tcp:0:interface=127.0.0.1")
|
open(os.path.join(basedir, "webport"), "w").write("tcp:0:interface=127.0.0.1")
|
||||||
open(os.path.join(basedir, "run_helper"), "w").write("yes\n")
|
open(os.path.join(basedir, "run_helper"), "w").write("yes\n")
|
||||||
|
open(os.path.join(basedir, "sizelimit"), "w").write("10GB\n")
|
||||||
if i == 3:
|
if i == 3:
|
||||||
# client[3] runs a webserver and uses a helper, uses key_generator
|
# client[3] runs a webserver and uses a helper, uses key_generator
|
||||||
open(os.path.join(basedir, "webport"), "w").write("tcp:0:interface=127.0.0.1")
|
open(os.path.join(basedir, "webport"), "w").write("tcp:0:interface=127.0.0.1")
|
||||||
|
@ -473,6 +473,29 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
d.addCallback(self.failUnlessIsBarDotTxt)
|
d.addCallback(self.failUnlessIsBarDotTxt)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_PUT_FILEURL_named_bad(self):
|
||||||
|
base = "/file/%s" % urllib.quote(self._bar_txt_uri)
|
||||||
|
d = self.shouldFail2(error.Error, "test_PUT_FILEURL_named_bad",
|
||||||
|
"400 Bad Request",
|
||||||
|
"/file can only be used with GET or HEAD",
|
||||||
|
self.PUT, base + "/@@name=/blah.txt", "")
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_GET_DIRURL_named_bad(self):
|
||||||
|
base = "/file/%s" % urllib.quote(self._foo_uri)
|
||||||
|
d = self.shouldFail2(error.Error, "test_PUT_DIRURL_named_bad",
|
||||||
|
"400 Bad Request",
|
||||||
|
"is not a file-cap",
|
||||||
|
self.GET, base + "/@@name=/blah.txt")
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_GET_slash_file_bad(self):
|
||||||
|
d = self.shouldFail2(error.Error, "test_GET_slash_file_bad",
|
||||||
|
"404 Not Found",
|
||||||
|
"/file must be followed by a file-cap and a name",
|
||||||
|
self.GET, "/file")
|
||||||
|
return d
|
||||||
|
|
||||||
def test_GET_unhandled_URI_named(self):
|
def test_GET_unhandled_URI_named(self):
|
||||||
contents, n, newuri = self.makefile(12)
|
contents, n, newuri = self.makefile(12)
|
||||||
verifier_cap = n.get_verifier().to_string()
|
verifier_cap = n.get_verifier().to_string()
|
||||||
@ -484,6 +507,17 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
self.GET, base)
|
self.GET, base)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_GET_unhandled_URI(self):
|
||||||
|
contents, n, newuri = self.makefile(12)
|
||||||
|
verifier_cap = n.get_verifier().to_string()
|
||||||
|
base = "/uri/%s" % urllib.quote(verifier_cap)
|
||||||
|
# client.create_node_from_uri() can't handle verify-caps
|
||||||
|
d = self.shouldFail2(error.Error, "test_GET_unhandled_URI",
|
||||||
|
"400 Bad Request",
|
||||||
|
"is not a valid file- or directory- cap",
|
||||||
|
self.GET, base)
|
||||||
|
return d
|
||||||
|
|
||||||
def test_GET_FILEURL_save(self):
|
def test_GET_FILEURL_save(self):
|
||||||
d = self.GET(self.public_url + "/foo/bar.txt?filename=bar.txt&save=true")
|
d = self.GET(self.public_url + "/foo/bar.txt?filename=bar.txt&save=true")
|
||||||
# TODO: look at the headers, expect a Content-Disposition: attachment
|
# TODO: look at the headers, expect a Content-Disposition: attachment
|
||||||
@ -899,6 +933,33 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
d.addBoth(self.shouldRedirect, "/")
|
d.addBoth(self.shouldRedirect, "/")
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def shouldRedirect2(self, which, checker, callable, *args, **kwargs):
|
||||||
|
d = defer.maybeDeferred(callable, *args, **kwargs)
|
||||||
|
def done(res):
|
||||||
|
if isinstance(res, failure.Failure):
|
||||||
|
res.trap(error.PageRedirect)
|
||||||
|
statuscode = res.value.status
|
||||||
|
target = res.value.location
|
||||||
|
return checker(statuscode, target)
|
||||||
|
self.fail("%s: callable was supposed to redirect, not return '%s'"
|
||||||
|
% (which, res))
|
||||||
|
d.addBoth(done)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_POST_upload_no_link_whendone_results(self):
|
||||||
|
def check(statuscode, target):
|
||||||
|
self.failUnlessEqual(statuscode, str(http.FOUND))
|
||||||
|
self.failUnless(target.startswith(self.webish_url), target)
|
||||||
|
return client.getPage(target, method="GET")
|
||||||
|
d = self.shouldRedirect2("test_POST_upload_no_link_whendone_results",
|
||||||
|
check,
|
||||||
|
self.POST, "/uri", t="upload",
|
||||||
|
when_done="/uri/%(uri)s",
|
||||||
|
file=("new.txt", self.NEWFILE_CONTENTS))
|
||||||
|
d.addCallback(lambda res:
|
||||||
|
self.failUnlessEqual(res, self.NEWFILE_CONTENTS))
|
||||||
|
return d
|
||||||
|
|
||||||
def test_POST_upload_no_link_mutable(self):
|
def test_POST_upload_no_link_mutable(self):
|
||||||
d = self.POST("/uri", t="upload", mutable="true",
|
d = self.POST("/uri", t="upload", mutable="true",
|
||||||
file=("new.txt", self.NEWFILE_CONTENTS))
|
file=("new.txt", self.NEWFILE_CONTENTS))
|
||||||
@ -1463,6 +1524,12 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_GET_URI_form_bad(self):
|
||||||
|
d = self.shouldFail2(error.Error, "test_GET_URI_form_bad",
|
||||||
|
"400 Bad Request", "GET /uri requires uri=",
|
||||||
|
self.GET, "/uri")
|
||||||
|
return d
|
||||||
|
|
||||||
def test_GET_rename_form(self):
|
def test_GET_rename_form(self):
|
||||||
d = self.GET(self.public_url + "/foo?t=rename-form&name=bar.txt",
|
d = self.GET(self.public_url + "/foo?t=rename-form&name=bar.txt",
|
||||||
followRedirect=True) # XXX [ ] todo: figure out why '.../foo' doesn't work
|
followRedirect=True) # XXX [ ] todo: figure out why '.../foo' doesn't work
|
||||||
|
Loading…
Reference in New Issue
Block a user