From: Brian Warner Date: Wed, 4 Feb 2015 06:09:40 +0000 (-0800) Subject: test that web.static= is really treated as a relative path X-Git-Tag: allmydata-tahoe-1.10.1a1~77^2 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz?a=commitdiff_plain;h=597542dc7791aabfe3688fcd09227aeb85ecdab1;p=tahoe-lafs%2Ftahoe-lafs.git test that web.static= is really treated as a relative path Also ssh.authorized_keys_file . --- diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index f5b0526b..94bfbdf5 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -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) ] diff --git a/src/allmydata/test/test_introducer.py b/src/allmydata/test/test_introducer.py index 21adb814..475b04db 100644 --- a/src/allmydata/test/test_introducer.py +++ b/src/allmydata/test/test_introducer.py @@ -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() diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 813856cb..e2029fee 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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):