mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 04:47:54 +00:00
Throw an error if user put an invalid port range in config file
Fix #117
This commit is contained in:
parent
3ba4789ba6
commit
ed39afbf3d
@ -140,7 +140,7 @@ class PortManager:
|
||||
"""
|
||||
|
||||
if end_port < start_port:
|
||||
raise Exception("Invalid port range {}-{}".format(start_port, end_port))
|
||||
raise HTTPConflict(text="Invalid port range {}-{}".format(start_port, end_port))
|
||||
|
||||
if socket_type == "UDP":
|
||||
socket_type = socket.SOCK_DGRAM
|
||||
|
@ -152,7 +152,7 @@ class Project:
|
||||
try:
|
||||
shutil.rmtree(old_path)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPConflict("Can't remove temporary directory {}: {}".format(old_path, e))
|
||||
raise aiohttp.web.HTTPConflict(text="Can't remove temporary directory {}: {}".format(old_path, e))
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -45,3 +45,13 @@ def test_release_udp_port():
|
||||
pm.reserve_udp_port(4242, project)
|
||||
pm.release_udp_port(4242, project)
|
||||
pm.reserve_udp_port(4242, project)
|
||||
|
||||
|
||||
def test_find_unused_port():
|
||||
p = PortManager().find_unused_port(1000, 10000)
|
||||
assert p is not None
|
||||
|
||||
|
||||
def test_find_unused_port_invalid_range():
|
||||
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||
p = PortManager().find_unused_port(10000, 1000)
|
||||
|
Loading…
Reference in New Issue
Block a user