diff --git a/src/_zkapauthorizer/tests/fixtures.py b/src/_zkapauthorizer/tests/fixtures.py index a01dc6ff430eef143a73c0b0242767514b136dbb..8803180f62410c0f62e7032563ef6af7ae142a3c 100644 --- a/src/_zkapauthorizer/tests/fixtures.py +++ b/src/_zkapauthorizer/tests/fixtures.py @@ -36,7 +36,7 @@ class AnonymousStorageServer(Fixture): :ivar tempdir: The path to the server's storage on the filesystem. - :ivar backend: The protocol-agnostic storage server backend. + :ivar storage_server: The protocol-agnostic storage server backend. :ivar clock: The ``IReactorTime`` provider to supply to ``StorageServer`` for its time-checking needs. @@ -45,11 +45,11 @@ class AnonymousStorageServer(Fixture): clock: Clock = attr.ib() tempdir: FilePath = attr.ib(default=None) - backend: StorageServer = attr.ib(default=None) + storage_server: StorageServer = attr.ib(default=None) def _setUp(self): self.tempdir = FilePath(self.useFixture(TempDir()).join(u"storage")) - self.backend = StorageServer( + self.storage_server = StorageServer( self.tempdir.path, b"x" * 20, clock=self.clock, diff --git a/src/_zkapauthorizer/tests/test_storage_protocol.py b/src/_zkapauthorizer/tests/test_storage_protocol.py index 2ee75aaae77a34dadf1c239c2397ceddcd852fc7..ed54432b9d36907a4baa826d91331b089306e8db 100644 --- a/src/_zkapauthorizer/tests/test_storage_protocol.py +++ b/src/_zkapauthorizer/tests/test_storage_protocol.py @@ -154,13 +154,13 @@ class ShareTests(TestCase): ) self.clock = Clock() - self.storage = self.useFixture( + self.anonymous_storage_server = self.useFixture( AnonymousStorageServer(self.clock), - ) + ).storage_server self.spending_recorder, spender = RecordingSpender.make() self.server = ZKAPAuthorizerStorageServer( - self.storage.backend, + self.anonymous_storage_server, self.pass_value, self.signing_key, spender, @@ -191,7 +191,7 @@ class ShareTests(TestCase): self.spending_recorder.reset() # And clean out any shares that might confuse things. - cleanup_storage_server(self.storage.backend) + cleanup_storage_server(self.anonymous_storage_server) def test_get_version(self): """ @@ -410,7 +410,7 @@ class ShareTests(TestCase): # Create some shares to alter the behavior of the next # allocate_buckets. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -479,7 +479,7 @@ class ShareTests(TestCase): ) self.assertThat( - dict(get_lease_grant_times(self.storage.backend, storage_index)), + dict(get_lease_grant_times(self.anonymous_storage_server, storage_index)), Equals(expected_leases), ) @@ -503,7 +503,7 @@ class ShareTests(TestCase): # Create a share we can toy with. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, add_lease_secret, cancel_secret, @@ -526,7 +526,7 @@ class ShareTests(TestCase): matches_spent_passes(self.public_key_hash, self.pass_factory.spent), ) - leases = list(self.storage.backend.get_leases(storage_index)) + leases = list(self.anonymous_storage_server.get_leases(storage_index)) self.assertThat(leases, HasLength(2)) def _stat_shares_immutable_test( @@ -539,7 +539,7 @@ class ShareTests(TestCase): # Create a share we can toy with. write_shares( - self.storage, + self.anonymous_storage_server, storage_index, {sharenum}, size, @@ -548,7 +548,7 @@ class ShareTests(TestCase): # Perhaps put some more leases on it. Leases might impact our # ability to determine share data size. for renew_secret in leases: - self.storage.backend.add_lease( + self.anonymous_storage_server.add_lease( storage_index, renew_secret, cancel_secret, @@ -589,8 +589,8 @@ class ShareTests(TestCase): size, when, leases, - lambda storage, storage_index, sharenums, size, canary: write_toy_shares( - storage.backend, + lambda storage_server, storage_index, sharenums, size, canary: write_toy_shares( + storage_server, storage_index, renew_secret, cancel_secret, @@ -616,7 +616,7 @@ class ShareTests(TestCase): """ assume(version not in (1, 2)) - sharedir = FilePath(self.storage.backend.sharedir).preauthChild( + sharedir = FilePath(self.anonymous_storage_server.sharedir).preauthChild( # storage_index_to_dir likes to return multiple segments # joined by pathsep storage_index_to_dir(storage_index), @@ -658,7 +658,7 @@ class ShareTests(TestCase): ``stat_shares`` declines to offer a result (by raising ``ValueError``). """ - sharedir = FilePath(self.storage.backend.sharedir).preauthChild( + sharedir = FilePath(self.anonymous_storage_server.sharedir).preauthChild( # storage_index_to_dir likes to return multiple segments # joined by pathsep storage_index_to_dir(storage_index), @@ -710,8 +710,8 @@ class ShareTests(TestCase): write real multi-gigabyte files to exercise the behavior. """ - def write_shares(storage, storage_index, sharenums, size, canary): - sharedir = FilePath(storage.backend.sharedir).preauthChild( + def write_shares(storage_server, storage_index, sharenums, size, canary): + sharedir = FilePath(storage_server.sharedir).preauthChild( # storage_index_to_dir likes to return multiple segments # joined by pathsep storage_index_to_dir(storage_index), @@ -816,7 +816,7 @@ class ShareTests(TestCase): """ # Create a share we can toy with. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -834,7 +834,7 @@ class ShareTests(TestCase): succeeded(Always()), ) self.assertThat( - FilePath(self.storage.backend.corruption_advisory_dir).children(), + FilePath(self.anonymous_storage_server.corruption_advisory_dir).children(), HasLength(1), ) @@ -924,7 +924,7 @@ class ShareTests(TestCase): self.assertThat( dict( get_lease_grant_times( - self.storage.backend, + self.anonymous_storage_server, storage_index, ) ), @@ -952,7 +952,9 @@ class ShareTests(TestCase): def leases(): return list( lease.to_mutable_data() - for lease in self.storage.backend.get_slot_leases(storage_index) + for lease in self.anonymous_storage_server.get_slot_leases( + storage_index + ) ) def write(): diff --git a/src/_zkapauthorizer/tests/test_storage_server.py b/src/_zkapauthorizer/tests/test_storage_server.py index defab2b6842a34ffc513cc9a444a61a6ea0dd890..a085bc5f8003f218250383ba8474917c3668ef8f 100644 --- a/src/_zkapauthorizer/tests/test_storage_server.py +++ b/src/_zkapauthorizer/tests/test_storage_server.py @@ -194,15 +194,15 @@ class PassValidationTests(TestCase): # the same time so we can do lease expiration calculations more # easily. self.clock.advance(time()) - self.storage = self.useFixture( + self.anonymous_storage_server = self.useFixture( AnonymousStorageServer(self.clock), - ) + ).storage_server self.signing_key = random_signing_key() self.public_key_hash = PublicKey.from_signing_key( self.signing_key ).encode_base64() self.storage_server = ZKAPAuthorizerStorageServer( - self.storage.backend, + self.anonymous_storage_server, self.pass_value, self.signing_key, spender, @@ -222,10 +222,10 @@ class PassValidationTests(TestCase): # Hypothesis and testtools fixtures don't play nicely together in a # way that allows us to just move everything from `setUp` into this # method. - cleanup_storage_server(self.storage.backend) + cleanup_storage_server(self.anonymous_storage_server) # One of the tests makes the server read-only partway through. Make # sure that doesn't leak into other examples. - self.storage.backend.readonly_storage = False + self.anonymous_storage_server.readonly_storage = False self.spending_recorder.reset() @@ -532,7 +532,7 @@ class PassValidationTests(TestCase): ) # Create some shares at a slot which will require lease renewal. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -805,7 +805,7 @@ class PassValidationTests(TestCase): # the subsequent `allocate_buckets` operation - but of which the # client is unaware. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -875,7 +875,7 @@ class PassValidationTests(TestCase): ): # Create some shares at a slot which will require lease renewal. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -938,7 +938,7 @@ class PassValidationTests(TestCase): # Put some shares up there to target with the add_lease operation. write_toy_shares( - self.storage.backend, + self.anonymous_storage_server, storage_index, renew_secret, cancel_secret, @@ -957,7 +957,7 @@ class PassValidationTests(TestCase): # Turn off space-allocating operations entirely. Since there will be # no space for a new lease, the operation will fail. - self.storage.backend.readonly_storage = True + self.anonymous_storage_server.readonly_storage = True try: self.storage_server.doRemoteCall(