mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
Fix a parsing bug that prevents IPv6 addresses from being used with add_host
Closes #8682
This commit is contained in:
parent
47d9e7ca93
commit
1886307845
2 changed files with 73 additions and 2 deletions
47
test/units/plugins/action/test_add_host.py
Normal file
47
test/units/plugins/action/test_add_host.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import unittest
|
||||
|
||||
from ansible.plugins.action import add_host
|
||||
|
||||
|
||||
class TestAddHost(unittest.TestCase):
|
||||
|
||||
def test_hostname(self):
|
||||
host, port = add_host._parse_ip_host_and_port('some-remote-host')
|
||||
assert host == 'some-remote-host'
|
||||
assert port is None
|
||||
|
||||
def test_hostname_with_port(self):
|
||||
host, port = add_host._parse_ip_host_and_port('some-remote-host:80')
|
||||
assert host == 'some-remote-host'
|
||||
assert port == '80'
|
||||
|
||||
def test_parse_ip_host_and_port_v4(self):
|
||||
host, port = add_host._parse_ip_host_and_port('8.8.8.8')
|
||||
assert host == '8.8.8.8'
|
||||
assert port is None
|
||||
|
||||
def test_parse_ip_host_and_port_v4_and_port(self):
|
||||
host, port = add_host._parse_ip_host_and_port('8.8.8.8:80')
|
||||
assert host == '8.8.8.8'
|
||||
assert port == '80'
|
||||
|
||||
def test_parse_ip_host_and_port_v6(self):
|
||||
host, port = add_host._parse_ip_host_and_port(
|
||||
'dead:beef:dead:beef:dead:beef:dead:beef'
|
||||
)
|
||||
assert host == 'dead:beef:dead:beef:dead:beef:dead:beef'
|
||||
assert port is None
|
||||
|
||||
def test_parse_ip_host_and_port_v6_with_brackets(self):
|
||||
host, port = add_host._parse_ip_host_and_port(
|
||||
'[dead:beef:dead:beef:dead:beef:dead:beef]'
|
||||
)
|
||||
assert host == 'dead:beef:dead:beef:dead:beef:dead:beef'
|
||||
assert port is None
|
||||
|
||||
def test_parse_ip_host_and_port_v6_with_brackets_and_port(self):
|
||||
host, port = add_host._parse_ip_host_and_port(
|
||||
'[dead:beef:dead:beef:dead:beef:dead:beef]:80'
|
||||
)
|
||||
assert host == 'dead:beef:dead:beef:dead:beef:dead:beef'
|
||||
assert port == '80'
|
Loading…
Add table
Add a link
Reference in a new issue