mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
verify behavior if there is a poorly behaved plugin
This commit is contained in:
parent
fd9ae24149
commit
1c68157c1f
@ -42,6 +42,9 @@ class DummyStorage(object):
|
||||
name = attr.ib()
|
||||
|
||||
def get_storage_server(self, configuration, get_anonymous_storage_server):
|
||||
if u"invalid" in configuration:
|
||||
raise Exception("The plugin is unhappy.")
|
||||
|
||||
announcement = {u"value": configuration.get(u"some", u"default-value")}
|
||||
storage_server = DummyStorageServer(get_anonymous_storage_server)
|
||||
return succeed(
|
||||
|
@ -27,9 +27,11 @@ from testtools.matchers import (
|
||||
MatchesListwise,
|
||||
MatchesDict,
|
||||
MatchesStructure,
|
||||
Always,
|
||||
)
|
||||
from testtools.twistedsupport import (
|
||||
succeeded,
|
||||
failed,
|
||||
)
|
||||
|
||||
import allmydata
|
||||
@ -1320,3 +1322,30 @@ introducer.furl = pb://abcde@nowhere/fake
|
||||
]),
|
||||
)),
|
||||
)
|
||||
|
||||
|
||||
def test_broken_storage_plugin(self):
|
||||
"""
|
||||
A storage plugin that raises an exception from ``get_storage_server``
|
||||
causes ``client.create_client_from_config`` to return ``Deferred``
|
||||
that fails.
|
||||
"""
|
||||
self.useFixture(UseTestPlugins())
|
||||
|
||||
config = client.config_from_string(
|
||||
self.basedir,
|
||||
u"tub.port",
|
||||
self.get_config(
|
||||
storage_enabled=True,
|
||||
more_storage=b"plugins=tahoe-lafs-dummy-v1",
|
||||
more_sections=(
|
||||
b"[storageserver.plugins.tahoe-lafs-dummy-v1]\n"
|
||||
# This will make it explode on instantiation.
|
||||
b"invalid = configuration\n"
|
||||
)
|
||||
),
|
||||
)
|
||||
self.assertThat(
|
||||
client.create_client_from_config(config, introducer_factory=MemoryIntroducerClient),
|
||||
failed(Always()),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user