Example #1
0
async def test_https_get_with_ssl_defaults(https_server):
    """
    An HTTPS request, with default SSL configuration set on the client.
    """
    conn = HTTPConnection(origin="https://127.0.0.1:8001/", verify=False)
    response = await conn.request("GET", "https://127.0.0.1:8001/")
    await response.read()
    assert response.status_code == 200
    assert response.content == b"Hello, world!"
Example #2
0
async def test_https_get_with_sll_overrides(https_server, backend):
    """
    An HTTPS request, with SSL configuration set on the request.
    """
    async with HTTPConnection(origin=https_server.url,
                              backend=backend) as conn:
        response = await conn.request("GET", https_server.url, verify=False)
        await response.read()
        assert response.status_code == 200
        assert response.content == b"Hello, world!"
Example #3
0
async def test_https_get_with_sll_overrides(https_server, backend):
    """
    An HTTPS request, with SSL configuration set on the request.
    """
    conn = HTTPConnection(origin="https://127.0.0.1:8001/", backend=backend)
    response = await conn.request("GET",
                                  "https://127.0.0.1:8001/",
                                  verify=False)
    await response.read()
    assert response.status_code == 200
    assert response.content == b"Hello, world!"
Example #4
0
async def test_https_get_with_ssl_defaults(https_server, ca_cert_pem_file,
                                           backend):
    """
    An HTTPS request, with default SSL configuration set on the client.
    """
    async with HTTPConnection(origin=https_server.url,
                              verify=ca_cert_pem_file,
                              backend=backend) as conn:
        response = await conn.request("GET", https_server.url)
        await response.read()
        assert response.status_code == 200
        assert response.content == b"Hello, world!"
Example #5
0
async def test_get(server):
    conn = HTTPConnection(origin="http://127.0.0.1:8000/")
    response = await conn.request("GET", "http://127.0.0.1:8000/")
    await response.read()
    assert response.status_code == 200
    assert response.content == b"Hello, world!"
Example #6
0
async def test_post(server):
    conn = HTTPConnection(origin="http://127.0.0.1:8000/")
    response = await conn.request("GET",
                                  "http://127.0.0.1:8000/",
                                  data=b"Hello, world!")
    assert response.status_code == 200
Example #7
0
async def test_post(server, backend):
    async with HTTPConnection(origin="http://127.0.0.1:8000/", backend=backend) as conn:
        response = await conn.request(
            "GET", "http://127.0.0.1:8000/", data=b"Hello, world!"
        )
        assert response.status_code == 200
Example #8
0
async def test_get(server, backend):
    async with HTTPConnection(origin=server.url, backend=backend) as conn:
        response = await conn.request("GET", server.url)
        await response.read()
        assert response.status_code == 200
        assert response.content == b"Hello, world!"
Example #9
0
async def test_post(server, backend):
    async with HTTPConnection(origin=server.url, backend=backend) as conn:
        response = await conn.request("GET", server.url, data=b"Hello, world!")
        assert response.status_code == 200
Example #10
0
async def test_premature_close(server, backend):
    with pytest.raises(exceptions.ConnectionClosed):
        async with HTTPConnection(origin=server.url, backend=backend) as conn:
            response = await conn.request(
                "GET", server.url.copy_with(path="/premature_close"))
            await response.read()