diff --git a/src/_secureaccesstokenauthorizer/_plugin.py b/src/_secureaccesstokenauthorizer/_plugin.py index 0350fa7e1fc73fc6453d50657373fe2342741f90..ba09200c97c053c641466f71da01fd93f39290ac 100644 --- a/src/_secureaccesstokenauthorizer/_plugin.py +++ b/src/_secureaccesstokenauthorizer/_plugin.py @@ -72,7 +72,9 @@ class SecureAccessTokenAuthorizer(object): def get_storage_client(self, configuration, announcement, get_rref): - return SecureAccessTokenAuthorizerStorageClient( - get_rref, - lambda: [b"x" * TOKEN_LENGTH], + return succeed( + SecureAccessTokenAuthorizerStorageClient( + get_rref, + lambda: [b"x" * TOKEN_LENGTH], + ) ) diff --git a/src/_secureaccesstokenauthorizer/tests/strategies.py b/src/_secureaccesstokenauthorizer/tests/strategies.py index e3f5e5f15f9df710d00838156998114f1dbcc1d2..7ecf774bc0fd063e184964efd5a7011e2cefcdd8 100644 --- a/src/_secureaccesstokenauthorizer/tests/strategies.py +++ b/src/_secureaccesstokenauthorizer/tests/strategies.py @@ -206,3 +206,10 @@ def test_and_write_vectors_for_shares(): # Just for practical purposes... max_size=8, ) + + +def announcements(): + """ + Build announcements for the SecureAccessTokenAuthorizer plugin. + """ + return just({}) diff --git a/src/_secureaccesstokenauthorizer/tests/test_plugin.py b/src/_secureaccesstokenauthorizer/tests/test_plugin.py index 3d83cad896b65929d0221a98b9164d2e413ce367..4c62ca74b70ae6e75db4ce396abdc656d825d5fd 100644 --- a/src/_secureaccesstokenauthorizer/tests/test_plugin.py +++ b/src/_secureaccesstokenauthorizer/tests/test_plugin.py @@ -47,6 +47,7 @@ from foolscap.ipb import ( from allmydata.interfaces import ( IFoolscapStoragePlugin, IAnnounceableStorageServer, + IStorageServer, ) from twisted.plugin import ( @@ -61,6 +62,7 @@ from twisted.plugins.secureaccesstokenauthorizer import ( from .strategies import ( configurations, + announcements, ) from .matchers import ( Provides, @@ -70,6 +72,10 @@ def get_anonymous_storage_server(): return None +def get_rref(): + return None + + class PluginTests(TestCase): """ Tests for ``twisted.plugins.secureaccesstokenauthorizer.storage_server``. @@ -91,6 +97,12 @@ class PluginTests(TestCase): verifyObject(IFoolscapStoragePlugin, storage_server) + +class ServerPluginTests(TestCase): + """ + Tests for the plugin's implementation of + ``IFoolscapStoragePlugin.get_storage_server``. + """ @given(configurations()) def test_returns_announceable(self, configuration): """ @@ -176,3 +188,27 @@ class PluginTests(TestCase): ), ), ) + + + +class ClientPluginTests(TestCase): + """ + Tests for the plugin's implementation of + ``IFoolscapStoragePlugin.get_storage_client``. + """ + @given(configurations(), announcements()) + def test_interface(self, configuration, announcement): + """ + ``get_storage_client`` returns a ``Deferred`` that fires with an object + which provides ``IStorageServer``. + """ + storage_client_deferred = storage_server.get_storage_client( + configuration, + announcement, + get_rref, + ) + + self.assertThat( + storage_client_deferred, + succeeded(Provides([IStorageServer])), + )