Merge pull request #1111 from Fenn-CS/3563.allmydata-node-catch-port-configs

Catch all port configurations
This commit is contained in:
May-Lee Sia 2021-08-24 17:21:05 +02:00 committed by GitHub
commit 2a7e3b3f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

0
newsfragments/3563.minor Normal file
View File

View File

@ -793,7 +793,7 @@ def _tub_portlocation(config, get_local_addresses_sync, allocate_tcp_port):
tubport = _convert_tub_port(cfg_tubport) tubport = _convert_tub_port(cfg_tubport)
for port in tubport.split(","): for port in tubport.split(","):
if port in ("0", "tcp:0"): if port in ("0", "tcp:0", "tcp:port=0", "tcp:0:interface=127.0.0.1"):
raise PortAssignmentRequired() raise PortAssignmentRequired()
if cfg_location is None: if cfg_location is None:

View File

@ -6,7 +6,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
from future.utils import PY2, native_str from future.utils import PY2
if PY2: 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 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
@ -530,6 +530,14 @@ def _stub_allocate_tcp_port():
""" """
return 999 return 999
def _stub_none():
"""
A function like ``_stub_allocate_tcp`` or ``_stub_get_local_addresses_sync``
but that return an empty list since ``allmydata.node._tub_portlocation`` requires a
callable for paramter 1 and 2 counting from 0.
"""
return []
class TestMissingPorts(unittest.TestCase): class TestMissingPorts(unittest.TestCase):
""" """
@ -550,7 +558,7 @@ class TestMissingPorts(unittest.TestCase):
) )
config = config_from_string(self.basedir, "portnum", config_data) config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(PortAssignmentRequired): with self.assertRaises(PortAssignmentRequired):
_tub_portlocation(config, None, None) _tub_portlocation(config, _stub_none, _stub_none)
def test_listen_on_zero_with_host(self): def test_listen_on_zero_with_host(self):
""" """
@ -563,10 +571,7 @@ class TestMissingPorts(unittest.TestCase):
) )
config = config_from_string(self.basedir, "portnum", config_data) config = config_from_string(self.basedir, "portnum", config_data)
with self.assertRaises(PortAssignmentRequired): with self.assertRaises(PortAssignmentRequired):
_tub_portlocation(config, None, None) _tub_portlocation(config, _stub_none, _stub_none)
test_listen_on_zero_with_host.todo = native_str( # type: ignore
"https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3563"
)
def test_parsing_tcp(self): def test_parsing_tcp(self):
""" """