def test_listen_on_zero(self): """ Trying to listen on port 0 should be an error """ basedir = self.mktemp() create_node_dir(basedir, "testing") with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write(BASE_CONFIG) f.write("tub.port = tcp:0\n") f.write("tub.location = AUTO\n") config = client.read_config(basedir, "client.port") i2p_provider = mock.Mock() tor_provider = mock.Mock() dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) t = FakeTub() with mock.patch("allmydata.node.Tub", return_value=t): with self.assertRaises(ValueError) as ctx: create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider) self.assertIn( "you must choose", str(ctx.exception), )
def _test_location(self, basedir, expected_addresses, tub_port=None, tub_location=None, local_addresses=None): create_node_dir(basedir, "testing") config_data = "[node]\n" if tub_port: config_data += "tub.port = {}\n".format(tub_port) if tub_location is not None: config_data += "tub.location = {}\n".format(tub_location) if local_addresses: self.patch(iputil, 'get_local_addresses_sync', lambda: local_addresses) tub = testing_tub(config_data) tub.setServiceParent(self.parent) class Foo(object): pass furl = tub.registerReference(Foo()) for address in expected_addresses: self.failUnlessIn(address, furl)
def test_multiple_ports(self): basedir = self.mktemp() create_node_dir(basedir, "testing") port1 = iputil.allocate_tcp_port() port2 = iputil.allocate_tcp_port() port = ("tcp:%d:interface=127.0.0.1,tcp:%d:interface=127.0.0.1" % (port1, port2)) location = "tcp:localhost:%d,tcp:localhost:%d" % (port1, port2) with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write(BASE_CONFIG) f.write("[node]\n") f.write("tub.port = %s\n" % port) f.write("tub.location = %s\n" % location) config = client.read_config(basedir, "client.port") i2p_provider = mock.Mock() tor_provider = mock.Mock() dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) t = FakeTub() with mock.patch("allmydata.node.Tub", return_value=t): create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider) self.assertEqual(t.listening_ports, ["tcp:%d:interface=127.0.0.1" % port1, "tcp:%d:interface=127.0.0.1" % port2])
def test_config_items(self): """ All items in a config section can be retrieved. """ basedir = u"test_node/test_config_items" create_node_dir(basedir, "testing") with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f: f.write( dedent(""" [node] nickname = foo timeout.disconnect = 12 """)) config = read_config(basedir, "portnum") self.assertEqual( config.items("node"), [ ("nickname", "foo"), ("timeout.disconnect", "12"), ], ) self.assertEqual( config.items("node", [("unnecessary", "default")]), [ ("nickname", "foo"), ("timeout.disconnect", "12"), ], )
def test_furl(self): basedir = "introducer.IntroducerNode.test_furl" create_node_dir(basedir, "testing") public_fn = os.path.join(basedir, "introducer.furl") private_fn = os.path.join(basedir, "private", "introducer.furl") q1 = yield create_introducer(basedir) del q1 # new nodes create unguessable furls in private/introducer.furl ifurl = fileutil.read(private_fn) self.failUnless(ifurl) ifurl = ifurl.strip() self.failIf(ifurl.endswith("/introducer"), ifurl) # old nodes created guessable furls in BASEDIR/introducer.furl guessable = ifurl[:ifurl.rfind("/")] + "/introducer" fileutil.write(public_fn, guessable + "\n", mode="w") # text # if we see both files, throw an error with self.assertRaises(FurlFileConflictError): yield create_introducer(basedir) # when we see only the public one, move it to private/ and use # the existing furl instead of creating a new one os.unlink(private_fn) q2 = yield create_introducer(basedir) del q2 self.failIf(os.path.exists(public_fn)) ifurl2 = fileutil.read(private_fn) self.failUnless(ifurl2) self.failUnlessEqual(ifurl2.strip(), guessable)
def create_introducer_webish(reactor, port_assigner, basedir): """ Create and start an introducer node and return it and its ``WebishServer`` service. :param reactor: The reactor to use to allow the introducer node to use to listen for connections. :param SameProcessStreamEndpointAssigner port_assigner: The assigner to use to assign a listening port for the introducer node. :param bytes basedir: A non-existant path where the introducer node will be created. :return Deferred[(_IntroducerNode, WebishServer)]: A Deferred that fires with the node and its webish service. """ node.create_node_dir(basedir, "testing") _, port_endpoint = port_assigner.assign(reactor) with open(join(basedir, "tahoe.cfg"), "w") as f: f.write("[node]\n" "tub.location = 127.0.0.1:1\n" + "web.port = {}\n".format(port_endpoint)) intro_node = yield create_introducer(basedir) ws = intro_node.getServiceNamed("webish") yield fireEventually(None) intro_node.startService() defer.returnValue((intro_node, ws))
def test_listen_on_zero(self): """ Trying to listen on port 0 should be an error """ basedir = self.mktemp() create_node_dir(basedir, "testing") with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write(BASE_CONFIG) f.write("[node]\n") f.write("tub.port = tcp:0\n") f.write("tub.location = AUTO\n") config = client.read_config(basedir, "client.port") i2p_provider = mock.Mock() tor_provider = mock.Mock() dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) t = FakeTub() with mock.patch("allmydata.node.Tub", return_value=t): with self.assertRaises(ValueError) as ctx: create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider) self.assertIn( "you must choose", str(ctx.exception), )
def test_multiple_ports(self): basedir = self.mktemp() create_node_dir(basedir, "testing") port1 = iputil.allocate_tcp_port() port2 = iputil.allocate_tcp_port() port = ("tcp:%d:interface=127.0.0.1,tcp:%d:interface=127.0.0.1" % (port1, port2)) location = "tcp:localhost:%d,tcp:localhost:%d" % (port1, port2) with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write(BASE_CONFIG) f.write("tub.port = %s\n" % port) f.write("tub.location = %s\n" % location) config = client.read_config(basedir, "client.port") i2p_provider = mock.Mock() tor_provider = mock.Mock() dfh, fch = create_connection_handlers(None, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) t = FakeTub() with mock.patch("allmydata.node.Tub", return_value=t): create_main_tub(config, tub_options, dfh, fch, i2p_provider, tor_provider) self.assertEqual(t.listening_ports, ["tcp:%d:interface=127.0.0.1" % port1, "tcp:%d:interface=127.0.0.1" % port2])
def _test_location( self, expected_addresses, tub_port=None, tub_location=None, local_addresses=None, ): """ Verify that a Tub configured with the given *tub.port* and *tub.location* values generates fURLs with the given addresses in its location hints. :param [str] expected_addresses: The addresses which must appear in the generated fURL for the test to pass. All addresses must appear. :param tub_port: If not ``None`` then a value for the *tub.port* configuration item. :param tub_location: If not ``None`` then a value for the *tub.port* configuration item. :param local_addresses: If not ``None`` then a list of addresses to supply to the system under test as local addresses. """ from twisted.internet import reactor basedir = self.mktemp() create_node_dir(basedir, "testing") if tub_port is None: # Always configure a usable tub.port address instead of relying on # the automatic port assignment. The automatic port assignment is # prone to collisions and spurious test failures. _, tub_port = self.port_assigner.assign(reactor) config_data = "[node]\n" config_data += "tub.port = {}\n".format(tub_port) # If they wanted a certain location, go for it. This probably won't # agree with the tub.port value we set but that only matters if # anything tries to use this to establish a connection ... which # nothing in this test suite will. if tub_location is not None: config_data += "tub.location = {}\n".format(tub_location) if local_addresses is not None: self.patch(iputil, 'get_local_addresses_sync', lambda: local_addresses) tub = testing_tub(reactor, config_data) class Foo(object): pass furl = tub.registerReference(Foo()) for address in expected_addresses: self.assertIn(address, furl)
def test_disabled(self): basedir = "test_node/test_disabled" create_node_dir(basedir, "testing") f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt') f.write(BASE_CONFIG) f.write(NOLISTEN) f.write(DISABLE_STORAGE) f.close() n = yield client.create_client(basedir) self.assertEqual(n.tub.getListeners(), [])
def test_private_config_missing(self): """ a missing config with no default is an error """ basedir = u"test_node/test_private_config_missing" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") with self.assertRaises(MissingConfigEntry): config.get_or_create_private_config("foo")
def test_private_config_missing(self): """ a missing config with no default is an error """ basedir = u"test_node/test_private_config_missing" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") with self.assertRaises(MissingConfigEntry): config.get_or_create_private_config("foo")
def test_disabled(self): basedir = "test_node/test_disabled" create_node_dir(basedir, "testing") f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt') f.write(BASE_CONFIG) f.write(NOLISTEN) f.write(DISABLE_STORAGE) f.close() n = yield client.create_client(basedir) self.assertEqual(n.tub.getListeners(), [])
def test_web_static(self): basedir = u"introducer.Node.test_web_static" create_node_dir(basedir, "testing") 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 = yield create_introducer(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_private_config_unreadable(self): """ Asking for inaccessible private config is an error """ basedir = u"test_node/test_private_config_unreadable" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") config.get_or_create_private_config("foo", "contents") fname = os.path.join(basedir, "private", "foo") os.chmod(fname, 0) with self.assertRaises(Exception): config.get_or_create_private_config("foo")
def test_logdir_is_str(self): basedir = "test_node/test_logdir_is_str" ns = Namespace() ns.called = False def call_setLogDir(logdir): ns.called = True self.failUnless(isinstance(logdir, str), logdir) self.patch(foolscap.logging.log, 'setLogDir', call_setLogDir) create_node_dir(basedir, "nothing to see here") yield client.create_client(basedir) self.failUnless(ns.called)
def test_port_none_introducer(self): basedir = "test_node/test_port_none_introducer" create_node_dir(basedir, "testing") with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f: f.write("[node]\n") f.write("tub.port = disabled\n") f.write("tub.location = disabled\n") with self.assertRaises(ValueError) as ctx: yield create_introducer(basedir) self.assertIn( "we are Introducer, but tub is not listening", str(ctx.exception), )
def test_logdir_is_str(self): basedir = "test_node/test_logdir_is_str" ns = Namespace() ns.called = False def call_setLogDir(logdir): ns.called = True self.failUnless(isinstance(logdir, str), logdir) self.patch(foolscap.logging.log, 'setLogDir', call_setLogDir) create_node_dir(basedir, "nothing to see here") yield client.create_client(basedir) self.failUnless(ns.called)
def test_port_none_introducer(self): basedir = "test_node/test_port_none_introducer" create_node_dir(basedir, "testing") with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f: f.write("[node]\n") f.write("tub.port = disabled\n") f.write("tub.location = disabled\n") with self.assertRaises(ValueError) as ctx: yield create_introducer(basedir) self.assertIn( "we are Introducer, but tub is not listening", str(ctx.exception), )
def test_private_config_unreadable(self): """ Asking for inaccessible private config is an error """ basedir = u"test_node/test_private_config_unreadable" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") config.get_or_create_private_config("foo", "contents") fname = os.path.join(basedir, "private", "foo") os.chmod(fname, 0) with self.assertRaises(Exception): config.get_or_create_private_config("foo")
def test_private_config_unreadable_preexisting(self): """ error if reading private config data fails """ basedir = u"test_node/test_private_config_unreadable_preexisting" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") fname = os.path.join(basedir, "private", "foo") with open(fname, "w") as f: f.write("stuff") os.chmod(fname, 0) with self.assertRaises(Exception): config.get_private_config("foo")
def test_secrets_dir_protected(self): if "win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(): # We don't know how to test that unprivileged users can't read this # thing. (Also we don't know exactly how to set the permissions so # that unprivileged users can't read this thing.) raise unittest.SkipTest("We don't know how to set permissions on Windows.") basedir = "test_node/test_secrets_dir_protected" create_node_dir(basedir, "nothing to see here") # make sure private dir was created with correct modes privdir = os.path.join(basedir, "private") st = os.stat(privdir) bits = stat.S_IMODE(st[stat.ST_MODE]) self.failUnless(bits & 0o001 == 0, bits)
def test_private_config_unreadable_preexisting(self): """ error if reading private config data fails """ basedir = u"test_node/test_private_config_unreadable_preexisting" create_node_dir(basedir, "testing") config = read_config(basedir, "portnum") fname = os.path.join(basedir, "private", "foo") with open(fname, "w") as f: f.write("stuff") os.chmod(fname, 0) with self.assertRaises(Exception): config.get_private_config("foo")
def test_disabled_but_storage(self): basedir = "test_node/test_disabled_but_storage" create_node_dir(basedir, "testing") f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt') f.write(BASE_CONFIG) f.write(NOLISTEN) f.write(ENABLE_STORAGE) f.close() with self.assertRaises(ValueError) as ctx: yield client.create_client(basedir) self.assertIn( "storage is enabled, but tub is not listening", str(ctx.exception), )
def test_disabled_but_storage(self): basedir = "test_node/test_disabled_but_storage" create_node_dir(basedir, "testing") f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt') f.write(BASE_CONFIG) f.write(NOLISTEN) f.write(ENABLE_STORAGE) f.close() with self.assertRaises(ValueError) as ctx: yield client.create_client(basedir) self.assertIn( "storage is enabled, but tub is not listening", str(ctx.exception), )
def test_secrets_dir_protected(self): if "win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(): # We don't know how to test that unprivileged users can't read this # thing. (Also we don't know exactly how to set the permissions so # that unprivileged users can't read this thing.) raise unittest.SkipTest("We don't know how to set permissions on Windows.") basedir = "test_node/test_secrets_dir_protected" create_node_dir(basedir, "nothing to see here") # make sure private dir was created with correct modes privdir = os.path.join(basedir, "private") st = os.stat(privdir) bits = stat.S_IMODE(st[stat.ST_MODE]) self.failUnless(bits & 0o001 == 0, bits)
def create_introducer(basedir=u"."): """ :returns: a Deferred that yields a new _IntroducerNode instance """ try: # see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2946 from twisted.internet import reactor if not os.path.exists(basedir): create_node_dir(basedir, INTRODUCER_README) config = read_config( basedir, u"client.port", generated_files=["introducer.furl"], _valid_config=_valid_config(), ) i2p_provider = create_i2p_provider(reactor, config) tor_provider = create_tor_provider(reactor, config) default_connection_handlers, foolscap_connection_handlers = create_connection_handlers( reactor, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) # we don't remember these because the Introducer doesn't make # outbound connections. i2p_provider = None tor_provider = None main_tub = create_main_tub( config, tub_options, default_connection_handlers, foolscap_connection_handlers, i2p_provider, tor_provider, ) control_tub = create_control_tub() node = _IntroducerNode( config, main_tub, control_tub, i2p_provider, tor_provider, ) return defer.succeed(node) except Exception: return Failure()
def test_ftp_create(self): """ configuration for sftpd results in it being started """ basedir = u"client.Basic.test_ftp_create" create_node_dir(basedir, "testing") with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write('[sftpd]\n' 'enabled = true\n' 'accounts.file = foo\n' 'host_pubkey_file = pubkey\n' 'host_privkey_file = privkey\n') with mock.patch('allmydata.frontends.sftpd.SFTPServer') as p: yield client.create_client(basedir) self.assertTrue(p.called)
def test_web_apiauthtoken(self): """ Client loads the proper API auth token from disk """ basedir = u"client.Basic.test_web_apiauthtoken" create_node_dir(basedir, "testing") c = yield client.create_client(basedir) # this must come after we create the client, as it will create # a new, random authtoken itself with open(os.path.join(basedir, "private", "api_auth_token"), "w") as f: f.write("deadbeef") token = c.get_auth_token() self.assertEqual("deadbeef", token)
def test_web_apiauthtoken(self): """ Client loads the proper API auth token from disk """ basedir = u"client.Basic.test_web_apiauthtoken" create_node_dir(basedir, "testing") c = yield client.create_client(basedir) # this must come after we create the client, as it will create # a new, random authtoken itself with open(os.path.join(basedir, "private", "api_auth_token"), "w") as f: f.write("deadbeef") token = c.get_auth_token() self.assertEqual("deadbeef", token)
def test_ftp_create(self): """ configuration for sftpd results in it being started """ basedir = u"client.Basic.test_ftp_create" create_node_dir(basedir, "testing") with open(os.path.join(basedir, "tahoe.cfg"), "w") as f: f.write( '[sftpd]\n' 'enabled = true\n' 'accounts.file = foo\n' 'host_pubkey_file = pubkey\n' 'host_privkey_file = privkey\n' ) with mock.patch('allmydata.frontends.sftpd.SFTPServer') as p: yield client.create_client(basedir) self.assertTrue(p.called)
def test_config_items_missing_section(self): """ If a default is given for a missing section, the default is used. Lacking both default and section, an error is raised. """ basedir = self.mktemp() create_node_dir(basedir, "testing") with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f: f.write("") config = read_config(basedir, "portnum") with self.assertRaises(configparser.NoSectionError): config.items("nosuch") default = [("hello", "world")] self.assertEqual(config.items("nosuch", default), default)
def _test_location( self, expected_addresses, tub_port=None, tub_location=None, local_addresses=None, ): """ Verify that a Tub configured with the given *tub.port* and *tub.location* values generates fURLs with the given addresses in its location hints. :param [str] expected_addresses: The addresses which must appear in the generated fURL for the test to pass. All addresses must appear. :param tub_port: If not ``None`` then a value for the *tub.port* configuration item. :param tub_location: If not ``None`` then a value for the *tub.port* configuration item. :param local_addresses: If not ``None`` then a list of addresses to supply to the system under test as local addresses. """ basedir = self.mktemp() create_node_dir(basedir, "testing") config_data = "[node]\n" if tub_port: config_data += "tub.port = {}\n".format(tub_port) if tub_location is not None: config_data += "tub.location = {}\n".format(tub_location) if local_addresses is not None: self.patch(iputil, 'get_local_addresses_sync', lambda: local_addresses) tub = testing_tub(config_data) class Foo(object): pass furl = tub.registerReference(Foo()) for address in expected_addresses: self.assertIn(address, furl)
def create_introducer(basedir=u"."): """ :returns: a Deferred that yields a new _IntroducerNode instance """ try: # see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2946 from twisted.internet import reactor if not os.path.exists(basedir): create_node_dir(basedir, INTRODUCER_README) config = read_config( basedir, u"client.port", generated_files=["introducer.furl"], _valid_config_sections=_valid_config_sections, ) i2p_provider = create_i2p_provider(reactor, config) tor_provider = create_tor_provider(reactor, config) default_connection_handlers, foolscap_connection_handlers = create_connection_handlers(reactor, config, i2p_provider, tor_provider) tub_options = create_tub_options(config) # we don't remember these because the Introducer doesn't make # outbound connections. i2p_provider = None tor_provider = None main_tub = create_main_tub( config, tub_options, default_connection_handlers, foolscap_connection_handlers, i2p_provider, tor_provider, ) control_tub = create_control_tub() node = _IntroducerNode( config, main_tub, control_tub, i2p_provider, tor_provider, ) return defer.succeed(node) except Exception: return Failure()
def _test_location(self, basedir, expected_addresses, tub_port=None, tub_location=None, local_addresses=None): create_node_dir(basedir, "testing") config_data = "[node]\n" if tub_port: config_data += "tub.port = {}\n".format(tub_port) if tub_location is not None: config_data += "tub.location = {}\n".format(tub_location) if local_addresses: self.patch(iputil, 'get_local_addresses_sync', lambda: local_addresses) tub = testing_tub(config_data) tub.setServiceParent(self.parent) class Foo(object): pass furl = tub.registerReference(Foo()) for address in expected_addresses: self.failUnlessIn(address, furl)
def create_client(basedir=u".", _client_factory=None): """ Creates a new client instance (a subclass of Node). :param unicode basedir: the node directory (which may not exist yet) :param _client_factory: (for testing) a callable that returns an instance of :class:`allmydata.node.Node` (or a subclass). By default this is :class:`allmydata.client._Client` :returns: Deferred yielding an instance of :class:`allmydata.client._Client` """ try: node.create_node_dir(basedir, CLIENT_README) config = read_config(basedir, u"client.port") # following call is async return create_client_from_config( config, _client_factory=_client_factory, ) except Exception: return Failure()
def test_welcome(self): basedir = self.mktemp() node.create_node_dir(basedir, "testing") with open(join(basedir, "tahoe.cfg"), "w") as f: f.write( "[node]\n" "tub.location = 127.0.0.1:1\n" "web.port = tcp:0\n" ) self.node = yield create_introducer(basedir) self.ws = self.node.getServiceNamed("webish") yield fireEventually(None) self.node.startService() url = "http://localhost:%d/" % self.ws.getPortnum() res = yield do_http("get", url) self.failUnlessIn('Welcome to the Tahoe-LAFS Introducer', res) self.failUnlessIn(FAVICON_MARKUP, res) self.failUnlessIn('Page rendered at', res) self.failUnlessIn('Tahoe-LAFS code imported from:', res)
def create_client(basedir=u".", _client_factory=None): """ Creates a new client instance (a subclass of Node). :param unicode basedir: the node directory (which may not exist yet) :param _client_factory: (for testing) a callable that returns an instance of :class:`allmydata.node.Node` (or a subclass). By default this is :class:`allmydata.client._Client` :returns: Deferred yielding an instance of :class:`allmydata.client._Client` """ try: node.create_node_dir(basedir, CLIENT_README) config = read_config(basedir, u"client.port") # following call is async return create_client_from_config( config, _client_factory=_client_factory, ) except Exception: return defer.fail()
def test_welcome(self): basedir = self.mktemp() node.create_node_dir(basedir, "testing") _, port_endpoint = self.port_assigner.assign(reactor) with open(join(basedir, "tahoe.cfg"), "w") as f: f.write( "[node]\n" "tub.location = 127.0.0.1:1\n" + "web.port = {}\n".format(port_endpoint) ) self.node = yield create_introducer(basedir) self.ws = self.node.getServiceNamed("webish") yield fireEventually(None) self.node.startService() url = "http://localhost:%d/" % self.ws.getPortnum() res = yield do_http("get", url) self.failUnlessIn('Welcome to the Tahoe-LAFS Introducer', res) self.failUnlessIn(FAVICON_MARKUP, res) self.failUnlessIn('Page rendered at', res) self.failUnlessIn('Tahoe-LAFS code imported from:', res)
def test_welcome(self): basedir = self.mktemp() node.create_node_dir(basedir, "testing") _, port_endpoint = self.port_assigner.assign(reactor) with open(join(basedir, "tahoe.cfg"), "w") as f: f.write("[node]\n" "tub.location = 127.0.0.1:1\n" + "web.port = {}\n".format(port_endpoint)) self.node = yield create_introducer(basedir) self.ws = self.node.getServiceNamed("webish") yield fireEventually(None) self.node.startService() url = "http://localhost:%d/" % self.ws.getPortnum() res = yield do_http("get", url) soup = BeautifulSoup(res, 'html5lib') assert_soup_has_text(self, soup, u'Welcome to the Tahoe-LAFS Introducer') assert_soup_has_favicon(self, soup) assert_soup_has_text(self, soup, u'Page rendered at') assert_soup_has_text(self, soup, u'Tahoe-LAFS code imported from:')
def test_secrets_dir(self): basedir = "test_node/test_secrets_dir" create_node_dir(basedir, "testing") self.failUnless(os.path.exists(os.path.join(basedir, "private")))
def setUp(self): self.basedir = self.mktemp() create_node_dir(self.basedir, "testing")
def setUp(self): self.basedir = self.mktemp() create_node_dir(self.basedir, "testing")
def test_secrets_dir(self): basedir = "test_node/test_secrets_dir" create_node_dir(basedir, "testing") self.failUnless(os.path.exists(os.path.join(basedir, "private")))