Files
compliance-scan/tests/test_cli.py
2025-12-18 19:16:04 +01:00

27 lines
966 B
Python

"""Tests for CLI argument parsing."""
import pytest
from sslysze_scan.cli import parse_host_ports
class TestParseHostPorts:
"""Tests for parse_host_ports function."""
def test_parse_host_ports_multiple_ports(self) -> None:
"""Test parsing hostname with multiple ports."""
hostname, ports = parse_host_ports("example.com:443,636,993")
assert hostname == "example.com"
assert ports == [443, 636, 993]
def test_parse_host_ports_ipv6_multiple(self) -> None:
"""Test parsing IPv6 address with multiple ports."""
hostname, ports = parse_host_ports("[2001:db8::1]:443,636")
assert hostname == "2001:db8::1"
assert ports == [443, 636]
def test_parse_host_ports_invalid_port_range(self) -> None:
"""Test error when port number out of range."""
with pytest.raises(ValueError, match="Invalid port number.*Must be between"):
parse_host_ports("example.com:99999")