mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +00:00
Merge pull request #969 from LeastAuthority/3593.get_encryption_key-test
Add FileHandle.get_encryption_key test Fixes: ticket:3593
This commit is contained in:
commit
ab57746a85
0
newsfragments/3593.minor
Normal file
0
newsfragments/3593.minor
Normal file
@ -888,6 +888,34 @@ def is_happy_enough(servertoshnums, h, k):
|
||||
return True
|
||||
|
||||
|
||||
class FileHandleTests(unittest.TestCase):
|
||||
"""
|
||||
Tests for ``FileHandle``.
|
||||
"""
|
||||
def test_get_encryption_key_convergent(self):
|
||||
"""
|
||||
When ``FileHandle`` is initialized with a convergence secret,
|
||||
``FileHandle.get_encryption_key`` returns a deterministic result that
|
||||
is a function of that secret.
|
||||
"""
|
||||
secret = b"\x42" * 16
|
||||
handle = upload.FileHandle(BytesIO(b"hello world"), secret)
|
||||
handle.set_default_encoding_parameters({
|
||||
"k": 3,
|
||||
"happy": 5,
|
||||
"n": 10,
|
||||
# Remember this is the *max* segment size. In reality, the data
|
||||
# size is much smaller so the actual segment size incorporated
|
||||
# into the encryption key is also smaller.
|
||||
"max_segment_size": 128 * 1024,
|
||||
})
|
||||
|
||||
self.assertEqual(
|
||||
b64encode(self.successResultOf(handle.get_encryption_key())),
|
||||
b"oBcuR/wKdCgCV2GKKXqiNg==",
|
||||
)
|
||||
|
||||
|
||||
class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
|
||||
ShouldFailMixin):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user