From 02cb4105b3a182c82e8b2a2b66755dcac6385ac8 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 29 Jul 2022 09:43:37 -0400 Subject: [PATCH] A lot closer to passing grid manager integration tests. --- integration/test_grid_manager.py | 6 +++--- src/allmydata/cli/grid_manager.py | 4 ++++ src/allmydata/storage_client.py | 7 ++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/integration/test_grid_manager.py b/integration/test_grid_manager.py index 704dee04b..63ee827b0 100644 --- a/integration/test_grid_manager.py +++ b/integration/test_grid_manager.py @@ -194,7 +194,7 @@ def test_reject_storage_server(reactor, request, temp_dir, flog_gatherer, port_a "storage0", pubkey_str, stdinBytes=gm_config, ) - assert json.loads(gm_config)['storage_servers'].keys() == ['storage0'] + assert json.loads(gm_config)['storage_servers'].keys() == {'storage0'} print("inserting certificate") cert = yield _run_gm( @@ -221,7 +221,7 @@ def test_reject_storage_server(reactor, request, temp_dir, flog_gatherer, port_a config = configutil.get_config(join(diana.process.node_dir, "tahoe.cfg")) config.add_section("grid_managers") - config.set("grid_managers", "test", ed25519.string_from_verifying_key(gm_pubkey)) + config.set("grid_managers", "test", str(ed25519.string_from_verifying_key(gm_pubkey), "ascii")) with open(join(diana.process.node_dir, "tahoe.cfg"), "w") as f: config.write(f) @@ -235,7 +235,7 @@ def test_reject_storage_server(reactor, request, temp_dir, flog_gatherer, port_a yield util.run_tahoe( reactor, request, "--node-directory", diana.process.node_dir, "put", "-", - stdin="some content\n" * 200, + stdin=b"some content\n" * 200, ) assert False, "Should get a failure" except util.ProcessFailed as e: diff --git a/src/allmydata/cli/grid_manager.py b/src/allmydata/cli/grid_manager.py index 4ef53887c..d3a11b62d 100644 --- a/src/allmydata/cli/grid_manager.py +++ b/src/allmydata/cli/grid_manager.py @@ -225,3 +225,7 @@ def _config_path_from_option(config: str) -> Optional[FilePath]: if config == "-": return None return FilePath(config) + + +if __name__ == '__main__': + grid_manager() diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 91073579d..7fe4d6bd2 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -37,8 +37,9 @@ from os import urandom import re import time import hashlib - +from io import StringIO from configparser import NoSectionError +import json import attr from zope.interface import ( @@ -67,7 +68,7 @@ from allmydata.interfaces import ( IFoolscapStoragePlugin, ) from allmydata.grid_manager import ( - create_grid_manager_verifier, + create_grid_manager_verifier, SignedCertificate ) from allmydata.crypto import ( ed25519, @@ -289,7 +290,7 @@ class StorageFarmBroker(service.MultiService): handler_overrides = server.get("connections", {}) gm_verifier = create_grid_manager_verifier( self.storage_client_config.grid_manager_keys, - server["ann"].get("grid-manager-certificates", []), + [SignedCertificate.load(StringIO(json.dumps(data))) for data in server["ann"].get("grid-manager-certificates", [])], "pub-{}".format(str(server_id, "ascii")), # server_id is v0- not pub-v0-key .. for reasons? )