Skip to content

Commit

Permalink
Fix minimum and maximum version setting
Browse files Browse the repository at this point in the history
sethmlarson authored Mar 31, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 65e969d commit b5dd754
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ urllib3
trustme
requests
flaky
httpx
8 changes: 6 additions & 2 deletions src/truststore/_api.py
Original file line number Diff line number Diff line change
@@ -215,15 +215,19 @@ def maximum_version(self) -> ssl.TLSVersion:

@maximum_version.setter
def maximum_version(self, value: ssl.TLSVersion) -> None:
self._ctx.maximum_version = value
_original_super_SSLContext.maximum_version.__set__( # type: ignore[attr-defined]
self._ctx, value
)

@property
def minimum_version(self) -> ssl.TLSVersion:
return self._ctx.minimum_version

@minimum_version.setter
def minimum_version(self, value: ssl.TLSVersion) -> None:
self._ctx.minimum_version = value
_original_super_SSLContext.minimum_version.__set__( # type: ignore[attr-defined]
self._ctx, value
)

@property
def options(self) -> ssl.Options:
13 changes: 13 additions & 0 deletions tests/test_inject.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import ssl

import httpx
import pytest
import requests
import urllib3
@@ -106,3 +107,15 @@ def test_requests():

thread = asyncio.to_thread(test_requests)
await thread


@pytest.mark.asyncio
@pytest.mark.usefixtures("inject_truststore")
async def test_sync_httpx_works_with_inject(server: Server) -> None:
def test_httpx():
client = httpx.Client()
resp = client.request("GET", server.base_url)
assert resp.status_code == 200

thread = asyncio.to_thread(test_httpx)
await thread

0 comments on commit b5dd754

Please sign in to comment.