Skip to content

Commit

Permalink
Merge pull request #1330 from tahoe-lafs/4047.test-foolscap-to-http-u…
Browse files Browse the repository at this point in the history
…pgrade

Test foolscap to http upgrade

Fixes ticket:4047
  • Loading branch information
itamarst committed Sep 6, 2023
2 parents fbd3831 + 45e201a commit 9d018e1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Empty file added newsfragments/4047.minor
Empty file.
38 changes: 38 additions & 0 deletions src/allmydata/test/test_storage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
from allmydata.storage_client import (
IFoolscapStorageServer,
NativeStorageServer,
HTTPNativeStorageServer,
StorageFarmBroker,
StorageClientConfig,
MissingPlugin,
Expand Down Expand Up @@ -645,6 +646,43 @@ def test_static_servers(self):
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"
Expand Down

0 comments on commit 9d018e1

Please sign in to comment.