Skip to content

Commit

Permalink
Drop use of httpx as a test dependency (#7950)
Browse files Browse the repository at this point in the history
We only use it in one test and are getting rid of it as a real
dependency (see #7927), so let's just drop it.
  • Loading branch information
msullivan authored Oct 31, 2024
1 parent 63e6fc4 commit 3877b6b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ test = [
'sphinxcontrib-serializinghtml<1.1.10',
'sphinxcontrib-qthelp<1.0.7',
'sphinx_code_tabs~=0.5.3',

'httpx~=0.24.1',
]

docs = [
Expand Down
29 changes: 20 additions & 9 deletions tests/test_server_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
import tempfile
import time
import unittest
import urllib.error
import urllib.request
import uuid

import edgedb
import httpx
from edgedb import errors

from edb import protocol
Expand Down Expand Up @@ -1028,15 +1029,25 @@ async def test_server_ops_mtls_http_transports(self):
security=args.ServerSecurityMode.Strict,
) as sd:
def test(url):
resp = httpx.get(url, verify=sd.tls_cert_file)
self.assertFalse(resp.is_success)

resp = httpx.get(
url,
verify=sd.tls_cert_file,
cert=(str(client_ssl_cert_file), str(client_ssl_key_file)),
# Connection without the client cert fails
tls_context = ssl.create_default_context(
ssl.Purpose.SERVER_AUTH,
cafile=sd.tls_cert_file,
)
error_code = None
try:
resp = urllib.request.urlopen(url, context=tls_context)
except urllib.error.HTTPError as e:
error_code = e.code
self.assertEqual(error_code, 401)

# But once we load the client it will work
tls_context.load_cert_chain(
client_ssl_cert_file,
client_ssl_key_file,
)
self.assertTrue(resp.is_success)
resp = urllib.request.urlopen(url, context=tls_context)
self.assertEqual(resp.status, 200)

test(f'https://{sd.host}:{sd.port}/metrics')
test(f'https://{sd.host}:{sd.port}/server/status/alive')
Expand Down

0 comments on commit 3877b6b

Please sign in to comment.