Merge branch 'master' of github.com:tahoe-lafs/tahoe-lafs into 3788.refactor-src.test.mutable

This commit is contained in:
fenn-cs 2021-10-20 11:17:41 +01:00
commit 26419c40bc
7 changed files with 56 additions and 10 deletions

0
newsfragments/3812.minor Normal file
View File

View File

@ -0,0 +1 @@
The news file for future releases will include a section for changes with a security impact.

View File

@ -475,7 +475,7 @@ class Share(object):
# there was corruption somewhere in the given range
reason = "corruption in share[%d-%d): %s" % (start, start+offset,
str(f.value))
self._rref.callRemote(
return self._rref.callRemote(
"advise_corrupt_share", reason.encode("utf-8")
).addErrback(log.err, "Error from remote call to advise_corrupt_share")

View File

@ -254,7 +254,7 @@ class WriteBucketProxy(object):
return d
def abort(self):
self._rref.callRemote("abort").addErrback(log.err, "Error from remote call to abort an immutable write bucket")
return self._rref.callRemote("abort").addErrback(log.err, "Error from remote call to abort an immutable write bucket")
def get_servername(self):
return self._server.get_name()

View File

@ -1017,7 +1017,7 @@ class _StorageServer(object):
shnum,
reason,
):
self._rref.callRemote(
return self._rref.callRemote(
"advise_corrupt_share",
share_type,
storage_index,

View File

@ -20,7 +20,7 @@ if PY2:
from random import Random
from twisted.internet.defer import inlineCallbacks
from twisted.internet.defer import inlineCallbacks, returnValue
from foolscap.api import Referenceable, RemoteException
@ -405,12 +405,8 @@ class IStorageServerImmutableAPIsTestsMixin(object):
)
@inlineCallbacks
def test_bucket_advise_corrupt_share(self):
"""
Calling ``advise_corrupt_share()`` on a bucket returned by
``IStorageServer.get_buckets()`` does not result in error (other
behavior is opaque at this level of abstraction).
"""
def create_share(self):
"""Create a share, return the storage index."""
storage_index = new_storage_index()
(_, allocated) = yield self.storage_server.allocate_buckets(
storage_index,
@ -423,10 +419,31 @@ class IStorageServerImmutableAPIsTestsMixin(object):
yield allocated[0].callRemote("write", 0, b"0123456789")
yield allocated[0].callRemote("close")
returnValue(storage_index)
@inlineCallbacks
def test_bucket_advise_corrupt_share(self):
"""
Calling ``advise_corrupt_share()`` on a bucket returned by
``IStorageServer.get_buckets()`` does not result in error (other
behavior is opaque at this level of abstraction).
"""
storage_index = yield self.create_share()
buckets = yield self.storage_server.get_buckets(storage_index)
yield buckets[0].callRemote("advise_corrupt_share", b"OH NO")
@inlineCallbacks
def test_advise_corrupt_share(self):
"""
Calling ``advise_corrupt_share()`` on an immutable share does not
result in error (other behavior is opaque at this level of
abstraction).
"""
storage_index = yield self.create_share()
yield self.storage_server.advise_corrupt_share(
b"immutable", storage_index, 0, b"ono"
)
class IStorageServerMutableAPIsTestsMixin(object):
"""
@ -780,6 +797,29 @@ class IStorageServerMutableAPIsTestsMixin(object):
{0: [b"abcdefg"], 1: [b"0123456"], 2: [b"9876543"]},
)
@inlineCallbacks
def test_advise_corrupt_share(self):
"""
Calling ``advise_corrupt_share()`` on a mutable share does not
result in error (other behavior is opaque at this level of
abstraction).
"""
secrets = self.new_secrets()
storage_index = new_storage_index()
(written, _) = yield self.staraw(
storage_index,
secrets,
tw_vectors={
0: ([], [(0, b"abcdefg")], 7),
},
r_vector=[],
)
self.assertEqual(written, True)
yield self.storage_server.advise_corrupt_share(
b"mutable", storage_index, 0, b"ono"
)
class _FoolscapMixin(SystemTestMixin):
"""Run tests on Foolscap version of ``IStorageServer."""

View File

@ -12,6 +12,11 @@
"~",
]
[[tool.towncrier.type]]
directory = "security"
name = "Security-related Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "incompat"
name = "Backwards Incompatible Changes"