Skip to content
Snippets Groups Projects
Commit cfc15cca authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Test and fix get_version

parent 527e43b6
No related branches found
No related tags found
1 merge request!4Cryptoless Tahoe-LAFS storage server plugin
......@@ -129,6 +129,9 @@ class SecureAccessTokenAuthorizerStorageServer(Referenceable):
def _validate_tokens(self, tokens):
pass
def remote_get_version(self):
return self._original.remote_get_version()
def remote_allocate_buckets(self, tokens, *a, **kw):
self._validate_tokens(tokens)
return self._original.remote_allocate_buckets(*a, **kw)
......
......@@ -20,6 +20,8 @@ import attr
from testtools.matchers import (
Mismatch,
ContainsDict,
Always,
)
@attr.s
......@@ -38,3 +40,17 @@ class Provides(object):
return Mismatch("{} does not provide expected {}".format(
obj, ", ".join(str(iface) for iface in missing),
))
def matches_version_dictionary():
"""
Match the dictionary returned by Tahoe-LAFS'
``RIStorageServer.get_version`` which is also the dictionary returned by
our own ``RITokenAuthorizedStorageServer.get_version``.
"""
return ContainsDict({
# It has these two top-level keys, at least. Try not to be too
# fragile by asserting much more than that they are present.
b'application-version': Always(),
b'http://allmydata.org/tahoe/protocols/storage/v1': Always(),
})
......@@ -30,6 +30,9 @@ from testtools.matchers import (
Equals,
HasLength,
)
from testtools.twistedsupport import (
succeeded,
)
from testtools.twistedsupport._deferred import (
# I'd rather use https://twistedmatrix.com/trac/ticket/8900 but efforts
# there appear to have stalled.
......@@ -72,7 +75,9 @@ from .strategies import (
# Not really a strategy...
bytes_for_share,
)
from .matchers import (
matches_version_dictionary,
)
from ..api import (
SecureAccessTokenAuthorizerStorageServer,
SecureAccessTokenAuthorizerStorageClient,
......@@ -106,6 +111,7 @@ class LocalRemote(object):
)
class ShareTests(TestCase):
"""
Tests for interaction with shares.
......@@ -127,6 +133,16 @@ class ShareTests(TestCase):
get_tokens=get_tokens,
)
def test_get_version(self):
"""
Version information about the storage server can be retrieved using
*get_version*.
"""
self.assertThat(
self.client.get_version(),
succeeded(matches_version_dictionary()),
)
@given(
storage_index=storage_indexes(),
renew_secret=lease_renew_secrets(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment