Exemplo n.º 1
0
def test_patch_contextmanager_with_public_fqdn_ipv6():
    with patch_getaddrinfo({"example.org": "::1"}):
        r = socket.getaddrinfo("example.org",
                               80,
                               family=socket.AF_INET6,
                               proto=socket.IPPROTO_TCP)
        for (_, _, _, _, sockaddr) in r:
            assert sockaddr == ("::1", 80, 0, 0)
Exemplo n.º 2
0
def test_patch_contextmanager_with_another_hostname_ipv6():
    with patch_getaddrinfo({"localhost2": "1.2.3.4"}):
        r = socket.getaddrinfo("ip6-localhost",
                               80,
                               family=socket.AF_INET6,
                               proto=socket.IPPROTO_TCP)
        for (_, _, _, _, sockaddr) in r:
            assert sockaddr == ("::1", 80, 0, 0)
Exemplo n.º 3
0
def test_patch_contextmanager_with_ip_ipv6():
    with patch_getaddrinfo({"::1": "1::23"}):
        r = socket.getaddrinfo("::1",
                               80,
                               family=socket.AF_INET6,
                               proto=socket.IPPROTO_TCP)
        for (_, _, _, _, sockaddr) in r:
            assert sockaddr == ("1::23", 80, 0, 0)
Exemplo n.º 4
0
def test_patch_contextmanager_with_ip_ipv4():
    with patch_getaddrinfo({"127.0.0.1": "1.2.3.4"}):
        r = socket.getaddrinfo("127.0.0.1",
                               80,
                               family=socket.AF_INET,
                               proto=socket.IPPROTO_TCP)
        for (_, _, _, _, sockaddr) in r:
            assert sockaddr == ("1.2.3.4", 80)
Exemplo n.º 5
0
def test_patch_contextmanager_with_unknown_hostname():
    with patch_getaddrinfo({"UNKNOWN_HOST_AZ": "127.0.0.1"}):
        assert socket.getaddrinfo("UNKNOWN_HOST_AZ",
                                  80) == socket.getaddrinfo("127.0.0.1", 80)
Exemplo n.º 6
0
def test_patch_contextmanager_with_public_fqdn_and_a_name_for_addr_ipv6():
    with patch_getaddrinfo({"example.org": "ip6-localhost"}):
        family = socket.AF_INET6
        assert socket.getaddrinfo("example.org", 80,
                                  family=family) == socket.getaddrinfo(
                                      "ip6-localhost", 80, family=family)
Exemplo n.º 7
0
def test_patch_contextmanager_with_public_fqdn_and_a_name_for_addr():
    with patch_getaddrinfo({"example.org": "localhost"}):
        assert socket.getaddrinfo("example.org",
                                  80) == socket.getaddrinfo("localhost", 80)