2021-02-12 00:53:20 +00:00
|
|
|
import httpx
|
2021-04-03 03:42:28 +00:00
|
|
|
import pytest
|
2021-07-10 23:37:30 +00:00
|
|
|
import socket
|
2021-02-12 00:53:20 +00:00
|
|
|
|
|
|
|
|
2021-04-03 03:42:28 +00:00
|
|
|
@pytest.mark.serial
|
2021-02-12 00:53:20 +00:00
|
|
|
def test_serve_localhost_http(ds_localhost_http_server):
|
|
|
|
response = httpx.get("http://localhost:8041/_memory.json")
|
|
|
|
assert {
|
|
|
|
"database": "_memory",
|
|
|
|
"path": "/_memory",
|
|
|
|
"tables": [],
|
|
|
|
}.items() <= response.json().items()
|
|
|
|
|
|
|
|
|
2021-04-03 03:42:28 +00:00
|
|
|
@pytest.mark.serial
|
2021-02-12 00:53:20 +00:00
|
|
|
def test_serve_localhost_https(ds_localhost_https_server):
|
|
|
|
_, client_cert = ds_localhost_https_server
|
|
|
|
response = httpx.get("https://localhost:8042/_memory.json", verify=client_cert)
|
|
|
|
assert {
|
|
|
|
"database": "_memory",
|
|
|
|
"path": "/_memory",
|
|
|
|
"tables": [],
|
|
|
|
}.items() <= response.json().items()
|
2021-07-10 23:37:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.serial
|
2021-07-10 23:46:49 +00:00
|
|
|
@pytest.mark.skipif(
|
|
|
|
not hasattr(socket, "AF_UNIX"), reason="Requires socket.AF_UNIX support"
|
|
|
|
)
|
2021-07-10 23:37:30 +00:00
|
|
|
def test_serve_unix_domain_socket(ds_unix_domain_socket_server):
|
|
|
|
_, uds = ds_unix_domain_socket_server
|
|
|
|
transport = httpx.HTTPTransport(uds=uds)
|
|
|
|
client = httpx.Client(transport=transport)
|
|
|
|
response = client.get("http://localhost/_memory.json")
|
|
|
|
assert {
|
|
|
|
"database": "_memory",
|
|
|
|
"path": "/_memory",
|
|
|
|
"tables": [],
|
|
|
|
}.items() <= response.json().items()
|