Update unit tests to support HTTPS storage protocol on by default.

This commit is contained in:
Itamar Turner-Trauring 2023-07-26 14:05:15 -04:00
parent 0e72f3c97a
commit aef6373915
2 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,7 @@ if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import attr
from hyperlink import DecodedURL
from testtools.matchers import (
Mismatch,
@ -95,6 +96,7 @@ def matches_storage_announcement(basedir, anonymous=True, options=None):
}
if anonymous:
announcement[u"anonymous-storage-FURL"] = matches_furl()
announcement[u"anonymous-storage-NURLs"] = matches_nurls()
if options:
announcement[u"storage-options"] = MatchesListwise(options)
return MatchesStructure(
@ -112,6 +114,16 @@ def matches_furl():
return AfterPreprocessing(decode_furl, Always())
def matches_nurls():
"""
Matches a sequence of NURLs.
"""
return AfterPreprocessing(
lambda nurls: [DecodedURL.from_text(u) for u in nurls],
Always()
)
def matches_base32():
"""
Match any base32 encoded byte string.

View File

@ -742,13 +742,14 @@ storage:
self.assertTrue(done.called)
def test_should_we_use_http_default(self):
"""Default is to not use HTTP; this will change eventually"""
"""Default is to use HTTP; this will change eventually"""
basedir = self.mktemp()
node_config = config_from_string(basedir, "", "")
announcement = {ANONYMOUS_STORAGE_NURLS: ["pb://..."]}
self.assertFalse(
self.assertTrue(
StorageFarmBroker._should_we_use_http(node_config, announcement)
)
# Lacking NURLs, we can't use HTTP:
self.assertFalse(
StorageFarmBroker._should_we_use_http(node_config, {})
)