]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: improve test coverage further
authorBrian Warner <warner@lothar.com>
Tue, 17 Jul 2007 19:28:29 +0000 (12:28 -0700)
committerBrian Warner <warner@lothar.com>
Tue, 17 Jul 2007 19:28:29 +0000 (12:28 -0700)
src/allmydata/test/test_web.py
src/allmydata/webish.py

index f90cb6dad6c6e372dd2b4cd015c80d909a6fbb57..b6182949a6844cd679a35479176fd711c88b971b 100644 (file)
@@ -373,6 +373,11 @@ class Web(unittest.TestCase):
         d.addCallback(self.failUnlessIsBarDotTxt)
         return d
 
+    def test_GET_FILEURL_download(self): # YES
+        d = self.GET("/vdrive/global/foo/bar.txt?t=download")
+        d.addCallback(self.failUnlessIsBarDotTxt)
+        return d
+
     def test_GET_FILEURL_missing(self): # YES
         d = self.GET("/vdrive/global/foo/missing")
         d.addBoth(self.should404, "test_GET_FILEURL_missing")
@@ -697,6 +702,18 @@ class Web(unittest.TestCase):
         d.addCallback(_check)
         return d
 
+    def test_GET_DIRURL_localdir_nonabsolute(self): # YES
+        localdir = "web/nonabsolute/dirpath"
+        fileutil.make_dirs("web/nonabsolute")
+        d = self.GET("/vdrive/global/foo?t=download&localdir=%s" % localdir)
+        d.addBoth(self.shouldFail, error.Error, "localdir non-absolute",
+                  "403 Forbidden",
+                  "localfile= or localdir= requires an absolute path")
+        def _check(res):
+            self.failIf(os.path.exists(localdir))
+        d.addCallback(_check)
+        return d
+
     def touch(self, localdir, filename):
         path = os.path.join(localdir, filename)
         f = open(path, "w")
index 0dee3288fd3db24297c034748c8d69da0722f3b4..f8712cd4c4a716004d53debdb3a11856db21c4f0 100644 (file)
@@ -275,9 +275,6 @@ LOCALHOST = "127.0.0.1"
 class NeedLocalhostError:
     implements(inevow.IResource)
 
-    def locateChild(self, ctx, segments):
-        return rend.NotFound
-
     def renderHTTP(self, ctx):
         req = inevow.IRequest(ctx)
         req.setResponseCode(http.FORBIDDEN)
@@ -287,9 +284,6 @@ class NeedLocalhostError:
 class NeedAbsolutePathError:
     implements(inevow.IResource)
 
-    def locateChild(self, ctx, segments):
-        return rend.NotFound
-
     def renderHTTP(self, ctx):
         req = inevow.IRequest(ctx)
         req.setResponseCode(http.FORBIDDEN)