Skip to content

Commit

Permalink
Fix curl call to work with IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Aug 30, 2024
1 parent a0621ef commit a833793
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_port_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def test_multiple_open_ports(container: ContainerData, number: int, host):
def test_bind_to_address(addr: str, container: ContainerData, host) -> None:
"""address"""
for host_addr in _ADDRESSES:
cmd = f"{_CURL} http://{host_addr}:{container.forwarded_ports[0].host_port}"
# need to surround a ipv6 address in [] so that it can be distinguished
# from a port
formated_ip = f"[{host_addr}]" if ":" in host_addr else host_addr
cmd = f"{_CURL} http://{formated_ip}:{container.forwarded_ports[0].host_port}"
if addr == host_addr:
assert host.check_output(cmd).strip() == "Hello Green World!"
else:
Expand Down

0 comments on commit a833793

Please sign in to comment.