Files
jeb-utils/tests/unit/utils/test_is_valid_host.py
T

43 lines
1.0 KiB
Python

from src.jeb_utils.utils import is_valid_host
import pytest
@pytest.mark.parametrize('host,expected', [
('0.0.0.0', True),
('0.0.0.1', True),
('1.0.0.1', True),
('1.1.1.1', True),
('255.255.255.255', True),
('42.54.32.78', True),
('0.0.255.255', True),
('255.255.0.0', True),
('192.168.0.0', True),
('192.168.23.1', True),
('10.0.0.0', True),
('10.0.0.1', True),
('10.1.1.1', True),
('10.54.65.129', True),
('127.0.0.1', True),
('127.0.0.42', True),
('127.0.1.42', True),
('0.0.a0.0', False),
('a0.0.0.0', False),
('a0.0.,0.0', False),
('a0.0.0,0', False),
('a0.0.0,0.0', False),
('256.255.255.255', False),
('-1.0.0.0', False),
('0.0.0', False),
('0.0.1', False),
('1.0.0', False),
('1.0.1', False),
('1.1.1', False),
('0.0.0.0:0', False),
('0.0.0.0:1', False),
('0.0.0.0:65535', False),
('0.0.0.0:65536', False),
('', False),
('', False)
])
def test_is_valid_host(host, expected):
assert is_valid_host(host) == expected