fix more things

This commit is contained in:
meejah 2018-01-28 18:59:56 -07:00
parent 279bd814fc
commit 0e51bb183e
2 changed files with 8 additions and 5 deletions

View File

@ -194,6 +194,8 @@ def read_config(basedir, portnumfile, generated_files=[], _valid_config_sections
# make sure we have a private configuration area
fileutil.make_dirs(os.path.join(basedir, "private"), 0o700)
configutil.validate_config(config_fname, parser, _valid_config_sections())
return _Config(parser, portnumfile, basedir, config_fname)

View File

@ -38,8 +38,8 @@ class LoggingMultiService(service.MultiService):
def testing_tub(config_data=''):
from twisted.internet import reactor
from allmydata.node import create_i2p_provider, create_tor_provider
config = config_from_string(config_data, 'DEFAULT_PORTNUMFILE_BLANK')
basedir = 'dummy_basedir'
config = config_from_string(config_data, 'DEFAULT_PORTNUMFILE_BLANK', basedir)
fileutil.make_dirs(os.path.join(basedir, 'private'))
i2p_provider = create_i2p_provider(reactor, basedir, config)
@ -215,13 +215,14 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
config.get_or_create_private_config("foo")
def test_private_config(self):
basedir = "test_node/test_private_config"
basedir = u"test_node/test_private_config"
privdir = os.path.join(basedir, "private")
fileutil.make_dirs(privdir)
f = open(os.path.join(privdir, 'already'), 'wt')
f.write("secret")
f.close()
basedir = fileutil.abspath_expanduser_unicode(basedir)
config = config_from_string("", "", basedir)
self.assertEqual(config.get_private_config("already"), "secret")
@ -479,16 +480,16 @@ class TestMissingPorts(unittest.TestCase):
"tub.location is disabled, but not tub.port",
str(ctx.exception)
)
=======
config = config_from_string('', '')
basedir = fileutil.abspath_expanduser_unicode(basedir)
config = config_from_string('', '', basedir)
Node(config, None, None, None, None, basedir, False)
self.failUnless(ns.called)
class EmptyNode(Node):
def __init__(self):
config = config_from_string("", "no portfile")
config = config_from_string("", "no portfile", 'no basedir')
Node.__init__(self, config, 'no basedir')
EXPECTED = {
@ -668,7 +669,7 @@ class Listeners(unittest.TestCase):
# we're doing a lot of calling-into-setup-methods here, it might be
# better to just create a real Node instance, I'm not sure.
config = read_config(basedir, "client.port")
config = read_config(basedir, "client.port", _valid_config_sections=client_valid_config_sections)
i2p_provider = mock.Mock()
tor_provider = mock.Mock()