def test_parses(self, data): """ Configurations built by the strategy can be parsed. """ tempdir = self.useFixture(TempDir()) config_text = data.draw(tahoe_config_texts({})) note(config_text) config_from_string( tempdir.join(b"tahoe.ini"), b"tub.port", config_text.encode("utf-8"), )
def setUp(self): def format_config_items(config): return "\n".join(" = ".join((key, value)) for (key, value) in config.items()) if self.plugin_config is None: plugin_config_section = "" else: plugin_config_section = """ [storageclient.plugins.{storage_plugin}] {config} """.format( storage_plugin=self.storage_plugin, config=format_config_items(self.plugin_config), ) write_introducer( self.basedir, "default", self.introducer_furl, ) self.config = config_from_string( self.basedir.asTextMode().path, "tub.port", """ [node] {node_config} [client] storage.plugins = {storage_plugin} {plugin_config_section} """.format( storage_plugin=self.storage_plugin, node_config=format_config_items(self.node_config), plugin_config_section=plugin_config_section, ))
def test_get_token_count(self, token_count): """ ``get_token_count`` returns the integer value of the ``default-token-count`` item from the given configuration object. """ plugin_name = u"hello-world" if token_count is None: expected_count = NUM_TOKENS token_config = {} else: expected_count = token_count token_config = { u"default-token-count": u"{}".format(expected_count) } config_text = config_string_from_sections([{ u"storageclient.plugins." + plugin_name: token_config, }]) node_config = config_from_string( self.useFixture(TempDir()).join(b"tahoe"), u"tub.port", config_text.encode("utf-8"), ) self.assertThat( get_token_count(plugin_name, node_config), Equals(expected_count), )
def test_parses(self, data): """ Configurations built by the strategy can be parsed. """ tempdir = self.useFixture(TempDir()) config_text = data.draw( tahoe_config_texts( storage_client_plugins={}, shares=one_of( just((None, None, None)), share_parameters(), ), ), ) note(config_text) config_from_string( tempdir.join(b"tahoe.ini"), b"tub.port", config_text.encode("utf-8"), )
def minimal_tahoe_configs(storage_client_plugins=None): """ Build complete Tahoe-LAFS configurations for a node. """ if storage_client_plugins is None: storage_client_plugins = {} return tahoe_config_texts(storage_client_plugins, ).map( lambda config_text: lambda basedir, portnumfile: config_from_string( basedir, portnumfile, config_text.encode("utf-8"), ), )
def direct_tahoe_configs( zkapauthz_v1_configuration=client_dummyredeemer_configurations(), shares=just((None, None, None)), ): """ Build complete Tahoe-LAFS configurations including the zkapauthorizer client plugin section. :param shares: See ``tahoe_config_texts``. :return SearchStrategy[_Config]: A strategy that builds Tahoe config objects. """ config_texts = minimal_tahoe_configs( { u"privatestorageio-zkapauthz-v1": zkapauthz_v1_configuration, }, shares) return config_texts.map( lambda config_text: config_from_string( u"/dev/null/illegal", u"", config_text.encode("utf-8"), ), )
def test_mismatched_ristretto_issuer(self, config_text, announcement): """ ``get_storage_client`` raises an exception when called with an announcement and local configuration which specify different issuers. """ tempdir = self.useFixture(TempDir()) node_config = config_from_string( tempdir.join(b"node"), b"tub.port", config_text.encode("utf-8"), ) config_text = BytesIO() node_config.config.write(config_text) self.addDetail(u"config", text_content(config_text.getvalue())) self.addDetail(u"announcement", text_content(unicode(announcement))) self.assertThat( lambda: storage_server.get_storage_client( node_config, announcement, get_rref, ), raises(IssuerConfigurationMismatch), )
from allmydata.client import ( config_from_string, create_client_from_config, ) from allmydata.scripts.common import ( write_introducer, ) from ..crypto import ( ed25519, ) from .eliotutil import ( EliotLoggedRunTest, ) from .common_util import ShouldFailMixin # noqa: F401 TEST_RSA_KEY_SIZE = 522 EMPTY_CLIENT_CONFIG = config_from_string("/dev/null", "tub.port", "") @attr.s class MemoryIntroducerClient(object): """ A model-only (no behavior) stand-in for ``IntroducerClient``. """ tub = attr.ib() introducer_furl = attr.ib() nickname = attr.ib() my_version = attr.ib() oldest_supported = attr.ib() sequencer = attr.ib() cache_filepath = attr.ib()