Merge pull request #1330 from tahoe-lafs/4047.test-foolscap-to-http-upgrade

Test foolscap to http upgrade

Fixes ticket:4047
This commit is contained in:
Itamar Turner-Trauring 2023-09-06 09:54:21 -04:00 committed by GitHub
commit 9d018e1876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

0
newsfragments/4047.minor Normal file
View File

View File

@ -88,6 +88,7 @@ from allmydata.util import base32, yamlutil
from allmydata.storage_client import (
IFoolscapStorageServer,
NativeStorageServer,
HTTPNativeStorageServer,
StorageFarmBroker,
StorageClientConfig,
MissingPlugin,
@ -645,6 +646,43 @@ storage:
self.assertIdentical(s2, s)
self.assertEqual(s2.get_permutation_seed(), permseed)
def test_upgrade_from_foolscap_to_http(self):
"""
When an announcement is initially Foolscap but then switches to HTTP,
HTTP is used, assuming HTTP is enabled.
"""
tub_maker = lambda _: new_tub()
config = config_from_string(
"/dev/null", "", "[client]\nforce_foolscap = False\n"
)
broker = StorageFarmBroker(True, tub_maker, config)
broker.startService()
self.addCleanup(broker.stopService)
key_s = b'v0-1234-1'
ones = str(base32.b2a(b"1"), "utf-8")
initial_announcement = {
"service-name": "storage",
"anonymous-storage-FURL": f"pb://{ones}@nowhere/fake2",
"permutation-seed-base32": "bbbbbbbbbbbbbbbbbbbbbbbb",
}
broker._got_announcement(key_s, initial_announcement)
initial_service = broker.servers[key_s]
self.assertIsInstance(initial_service, NativeStorageServer)
self.assertTrue(initial_service.running)
self.assertIdentical(initial_service.parent, broker)
http_announcement = initial_announcement.copy()
http_announcement[ANONYMOUS_STORAGE_NURLS] = {f"pb://{ones}@nowhere/fake2#v=1"}
broker._got_announcement(key_s, http_announcement)
self.assertFalse(initial_service.running)
self.assertEqual(initial_service.parent, None)
new_service = broker.servers[key_s]
self.assertIsInstance(new_service, HTTPNativeStorageServer)
self.assertTrue(new_service.running)
self.assertIdentical(new_service.parent, broker)
def test_static_permutation_seed_pubkey(self):
broker = make_broker()
server_id = b"v0-4uazse3xb6uu5qpkb7tel2bm6bpea4jhuigdhqcuvvse7hugtsia"