31 lines
821 B
Python
31 lines
821 B
Python
from app.integrations.docker.ports import _get_service_binding, _replace_port_in_mapping
|
|
|
|
|
|
def test_get_service_binding_includes_loopback_hosts():
|
|
assert _get_service_binding("127.0.0.1:8080:80") == (8080, "127.0.0.1")
|
|
assert _get_service_binding("localhost:9081:5678") == (9081, "localhost")
|
|
|
|
|
|
def test_replace_port_in_mapping_can_force_loopback_host():
|
|
updated = _replace_port_in_mapping(
|
|
"9081:5678",
|
|
9081,
|
|
54001,
|
|
host_to="127.0.0.1",
|
|
rewrite_host=True,
|
|
)
|
|
|
|
assert updated == "127.0.0.1:54001:5678"
|
|
|
|
|
|
def test_replace_port_in_mapping_can_restore_unspecified_host():
|
|
restored = _replace_port_in_mapping(
|
|
"127.0.0.1:54001:5678",
|
|
54001,
|
|
9081,
|
|
host_to=None,
|
|
rewrite_host=True,
|
|
)
|
|
|
|
assert restored == "9081:5678"
|