Skip to content
Snippets Groups Projects
Unverified Commit b62644f9 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone Committed by GitHub
Browse files

Merge pull request #185 from PrivateStorageio/184.tahoe_configs-strategy

Introduce `direct_tahoe_configs` strategy
parents ccea44ad 5aedd55c
No related branches found
No related tags found
No related merge requests found
......@@ -181,18 +181,15 @@ def minimal_tahoe_configs(storage_client_plugins=None, shares=just((None, None,
Build complete Tahoe-LAFS configurations for a node.
:param shares: See ``tahoe_config_texts``.
:return SearchStrategy[unicode]: A strategy that builds unicode strings
which are Tahoe-LAFS configuration file contents.
"""
if storage_client_plugins is None:
storage_client_plugins = {}
return tahoe_config_texts(
storage_client_plugins,
shares,
).map(
lambda config_text: lambda basedir, portnumfile: config_from_string(
basedir,
portnumfile,
config_text.encode("utf-8"),
),
)
......@@ -310,7 +307,7 @@ def client_errorredeemer_configurations(details):
})
def tahoe_configs(
def direct_tahoe_configs(
zkapauthz_v1_configuration=client_dummyredeemer_configurations(),
shares=just((None, None, None)),
):
......@@ -319,10 +316,51 @@ def tahoe_configs(
client plugin section.
:param shares: See ``tahoe_config_texts``.
:return SearchStrategy[_Config]: A strategy that builds Tahoe config
objects.
"""
return minimal_tahoe_configs({
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 tahoe_configs(
zkapauthz_v1_configuration=client_dummyredeemer_configurations(),
shares=just((None, None, None)),
):
"""
Build complete Tahoe-LAFS configurations including the zkapauthorizer
client plugin section.
You probably want ``direct_tahoe_configs``.
:param shares: See ``tahoe_config_texts``.
:return SearchStrategy[str -> str -> _Config]: A strategy that builds
two-argument functions that return a config object. The two arguments
are the ``basedir`` and ``portnumfile`` arguments to Tahoe's
``config_from_string.``
"""
def path_setter(config):
def set_paths(basedir, portnumfile):
config._basedir = basedir.decode("ascii")
config.portnum_fname = portnumfile
return config
return set_paths
return direct_tahoe_configs(
zkapauthz_v1_configuration,
shares,
).map(
path_setter,
)
def share_parameters():
......
......@@ -83,6 +83,7 @@ from allmydata.interfaces import (
RIStorageServer,
)
from allmydata.client import (
config_from_string,
create_client_from_config,
)
......@@ -375,15 +376,16 @@ class ClientPluginTests(TestCase):
@given(tahoe_configs_with_mismatched_issuer, announcements())
def test_mismatched_ristretto_issuer(self, get_config, announcement):
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 = get_config(
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment