From c4c9d1389ef10236227d5a58927cebbb0907c3a1 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 29 Nov 2022 09:47:10 -0500 Subject: [PATCH] Try (but fail) to demonstrate the longname behavior --- setup.py | 2 +- src/allmydata/storage_client.py | 8 ++++---- src/allmydata/test/test_storage_client.py | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 78f7042a9..480cb0d88 100644 --- a/setup.py +++ b/setup.py @@ -111,7 +111,7 @@ install_requires = [ "pyrsistent", # A great way to define types of values. - "attrs >= 18.2.0", + "attrs >= 20.1.0", # WebSocket library for twisted and asyncio "autobahn >= 22.4.3", diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 5dc4beb22..2ecd3bc0c 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -39,6 +39,7 @@ from os import urandom from configparser import NoSectionError import attr +from attr import define from hyperlink import DecodedURL from zope.interface import ( Attribute, @@ -637,6 +638,7 @@ class _FoolscapStorage(object): @implementer(IFoolscapStorageServer) +@define class _NullStorage(object): """ Abstraction for *not* communicating with a storage server of a type with @@ -650,7 +652,7 @@ class _NullStorage(object): lease_seed = hashlib.sha256(b"").digest() name = "" - longname = "" + longname: str = "" def connect_to(self, tub, got_connection): return NonReconnector() @@ -784,9 +786,7 @@ def _make_storage_system( ) except MissingPlugin as e: _log.failure("Missing plugin") - ns = _NullStorage() - ns.longname = ''.format(e.args[0]) - return ns + return _NullStorage(''.format(e.args[0])) else: return _FoolscapStorage.from_announcement( server_id, diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py index 1a84f35ec..0c05be2e6 100644 --- a/src/allmydata/test/test_storage_client.py +++ b/src/allmydata/test/test_storage_client.py @@ -159,7 +159,7 @@ class GetConnectionStatus(unittest.TestCase): self.assertTrue(IConnectionStatus.providedBy(connection_status)) -class UnrecognizedAnnouncement(unittest.TestCase): +class UnrecognizedAnnouncement(SyncTestCase): """ Tests for handling of announcements that aren't recognized and don't use *anonymous-storage-FURL*. @@ -169,9 +169,14 @@ class UnrecognizedAnnouncement(unittest.TestCase): an announcement generated by a storage server plugin which is not loaded in the client. """ + plugin_name = u"tahoe-lafs-testing-v1" ann = { - u"name": u"tahoe-lafs-testing-v1", - u"any-parameter": 12345, + u"storage-options": [ + { + u"name": plugin_name, + u"any-parameter": 12345, + }, + ], } server_id = b"abc" @@ -234,6 +239,15 @@ class UnrecognizedAnnouncement(unittest.TestCase): server.get_foolscap_write_enabler_seed() server.get_nickname() + def test_longname(self) -> None: + """ + ``NativeStorageServer.get_longname`` describes the missing plugin. + """ + server = self.native_storage_server() + self.assertThat( + server.get_longname(), + Equals(''.format(self.plugin_name)), + ) class PluginMatchedAnnouncement(SyncTestCase):