def test_ipv6_wrong_address_family(self): """ Tests IPv6 address conversions """ address = "2607:f0d0:1002:0051:0000:0000:0000:0004" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET6, address) with pytest.raises(ValueError): addr_to_string(addr_fam, addr)
def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET, address) with pytest.raises(ValueError): addr_to_string(addr_fam, (addr,))
def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET, address) with pytest.raises(ValueError): addr_to_string(addr_fam, (addr, ))
def test_ipv4_address_conversion(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = socket.AF_INET assert address == addr_to_string(addr_fam, string_to_addr(addr_fam, address))
def test_ipv4_loopback_conversion(self): """ Tests IPv4 loopback address conversions """ address = "127.0.0.1" addr_fam = socket.AF_INET assert address == addr_to_string(addr_fam, string_to_addr(addr_fam, address))
def test_ipv6_address_conversion(self): """ Tests IPv6 address conversions """ address = "2607:f0d0:1002:0051:0000:0000:0000:0004" addr_fam = socket.AF_INET6 ipv6 = addr_to_string(addr_fam, string_to_addr(addr_fam, address)) assert ipv6 in (address, "2607:f0d0:1002:51::4")
def test_ipv6_loopback_conversion(self): """ Tests IPv6 loopback address conversions """ address = "::1" addr_fam = socket.AF_INET6 ipv6 = addr_to_string(addr_fam, string_to_addr(addr_fam, address)) assert ipv6 in "::1"
def dst_addr(self): header, dst_addr = self._get_from_headers("DstAddr") if dst_addr: return addr_to_string(self.address_family, dst_addr, self.encoding)
def src_addr(self): header, src_addr = self._get_from_headers("SrcAddr") if src_addr: return addr_to_string(self.address_family, src_addr, self.encoding)
def dst_addr(self): header, dst_addr = self._get_from_headers("DstAddr") if dst_addr: return addr_to_string(self.address_family, dst_addr)
def src_addr(self): header, src_addr = self._get_from_headers("SrcAddr") if src_addr: return addr_to_string(self.address_family, src_addr)