def test_matches_machine_hostname_returns_false_if_hostname_does_not_match( self, ) -> None: hosts = ["dummy", "0.0.0.0", "::2"] for host in hosts: with self.subTest(host=host): self.assertFalse(_matches_machine_hostname(host))
def test_matches_machine_hostname_returns_true_if_hostname_is_machine_address( self, ) -> None: addr_list = socket.getaddrinfo(socket.gethostname(), None, proto=socket.IPPROTO_TCP) for addr in (addr_info[4][0] for addr_info in addr_list): with self.subTest(addr=addr): self.assertTrue(_matches_machine_hostname(addr))
def test_matches_machine_hostname_returns_true_if_hostname_is_loopback( self) -> None: hosts = [ "localhost", "127.0.0.1", "::1", "0000:0000:0000:0000:0000:0000:0000:0001" ] for host in hosts: with self.subTest(host=host): self.assertTrue(_matches_machine_hostname(host))
def test_matches_machine_hostname_returns_true_if_hostname_is_machine_fqdn( self, ) -> None: host = socket.getfqdn() self.assertTrue(_matches_machine_hostname(host))