]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test that web.static= is really treated as a relative path
authorBrian Warner <warner@lothar.com>
Wed, 4 Feb 2015 06:09:40 +0000 (22:09 -0800)
committerBrian Warner <warner@lothar.com>
Wed, 4 Feb 2015 06:23:31 +0000 (22:23 -0800)
Also ssh.authorized_keys_file .

src/allmydata/test/test_client.py
src/allmydata/test/test_introducer.py
src/allmydata/webish.py

index f5b0526ba624b0f2588d86b2b2cf6ee44a75ea79..94bfbdf536556eae9b59c8735eba53400b837242 100644 (file)
@@ -6,6 +6,7 @@ import allmydata
 from allmydata.node import Node, OldConfigError, OldConfigOptionError, MissingConfigEntry, UnescapedHashError
 from allmydata import client
 from allmydata.storage_client import StorageFarmBroker
+from allmydata.manhole import AuthorizedKeysManhole
 from allmydata.util import base32, fileutil
 from allmydata.interfaces import IFilesystemNode, IFileNode, \
      IImmutableFileNode, IMutableFileNode, IDirectoryNode
@@ -174,6 +175,34 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
                            "reserved_space = bogus\n")
         self.failUnlessRaises(ValueError, client.Client, basedir)
 
+    def test_web_staticdir(self):
+        basedir = u"client.Basic.test_web_staticdir"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                       BASECONFIG +
+                       "[node]\n" +
+                       "web.port = tcp:0:interface=127.0.0.1\n" +
+                       "web.static = relative\n")
+        c = client.Client(basedir)
+        w = c.getServiceNamed("webish")
+        abs_basedir = fileutil.abspath_expanduser_unicode(basedir)
+        expected = fileutil.abspath_expanduser_unicode(u"relative", abs_basedir)
+        self.failUnlessReallyEqual(w.staticdir, expected)
+
+    def test_manhole_keyfile(self):
+        basedir = u"client.Basic.test_manhole_keyfile"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                       BASECONFIG +
+                       "[node]\n" +
+                       "ssh.port = tcp:0:interface=127.0.0.1\n" +
+                       "ssh.authorized_keys_file = relative\n")
+        c = client.Client(basedir)
+        m = [s for s in c if isinstance(s, AuthorizedKeysManhole)][0]
+        abs_basedir = fileutil.abspath_expanduser_unicode(basedir)
+        expected = fileutil.abspath_expanduser_unicode(u"relative", abs_basedir)
+        self.failUnlessReallyEqual(m.keyfile, expected)
+
     def _permute(self, sb, key):
         return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]
 
index 21adb814037bab21cd84f670ede6508fb19f1858..475b04dba6ac13b485d962210ecdc466513c9960 100644 (file)
@@ -28,7 +28,7 @@ class LoggingMultiService(service.MultiService):
     def log(self, msg, **kw):
         log.msg(msg, **kw)
 
-class Node(testutil.SignalMixin, unittest.TestCase):
+class Node(testutil.SignalMixin, testutil.ReallyEqualMixin, unittest.TestCase):
     def test_furl(self):
         basedir = "introducer.IntroducerNode.test_furl"
         os.mkdir(basedir)
@@ -74,6 +74,20 @@ class Node(testutil.SignalMixin, unittest.TestCase):
         d.addCallback(_check_furl)
         return d
 
+    def test_web_static(self):
+        basedir = u"introducer.Node.test_web_static"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                       "[node]\n" +
+                       "web.port = tcp:0:interface=127.0.0.1\n" +
+                       "web.static = relative\n")
+        c = IntroducerNode(basedir)
+        w = c.getServiceNamed("webish")
+        abs_basedir = fileutil.abspath_expanduser_unicode(basedir)
+        expected = fileutil.abspath_expanduser_unicode(u"relative", abs_basedir)
+        self.failUnlessReallyEqual(w.staticdir, expected)
+
+
 class ServiceMixin:
     def setUp(self):
         self.parent = LoggingMultiService()
index 813856cb02c53bdb81e06d3953281f20d803aae9..e2029feecd595ba21bf3516c880189065286569e 100644 (file)
@@ -147,6 +147,7 @@ class WebishServer(service.MultiService):
         self.site = site = appserver.NevowSite(self.root)
         self.site.requestFactory = MyRequest
         self.site.remember(MyExceptionHandler(), inevow.ICanHandleException)
+        self.staticdir = staticdir # so tests can check
         if staticdir:
             self.root.putChild("static", static.File(staticdir))
         if re.search(r'^\d', webport):