Skip to content

Commit e71ed01

Browse files
authored
Merge pull request #90 from kevin1024/test-on-3-13-and-pypy-3-10
2 parents f81b16b + c86126c commit e71ed01

19 files changed

+73
-275
lines changed

.github/workflows/main.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: [3.8, 3.9, '3.10', 3.11, 3.12, pypy-3.8, pypy-3.9]
16+
python-version: [3.8, 3.9, '3.10', 3.11, 3.12, 3.13, pypy-3.10]
1717
os: [macOS-latest, ubuntu-latest, windows-latest]
1818

1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v2
2222

2323
- name: Set Up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
cache: pip
28+
allow-prereleases: true
2829
cache-dependency-path: |
2930
pyproject.toml
3031
setup.cfg

pytest_httpbin/certs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def where():
1616
"""Return the preferred certificate bundle."""
1717
# vendored bundle inside Requests
18-
return os.path.join(os.path.dirname(__file__), "certs", "cacert.pem")
18+
return os.path.join(os.path.dirname(__file__), "certs", "client.pem")
1919

2020

2121
if __name__ == "__main__":

pytest_httpbin/certs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
generated with 'python -m trustme'

pytest_httpbin/certs/cacert.pem

Lines changed: 0 additions & 30 deletions
This file was deleted.

pytest_httpbin/certs/cert.pem

Lines changed: 0 additions & 26 deletions
This file was deleted.

pytest_httpbin/certs/client.pem

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIB0TCCAXegAwIBAgIUScnyyX1CI+ywC6GdKol8IIwuGnkwCgYIKoZIzj0EAwIw
3+
RDEbMBkGA1UECgwSdHJ1c3RtZSB2MS4xLjArZGV2MSUwIwYDVQQLDBxUZXN0aW5n
4+
IENBICNBdXNVcWJaNG81d3pjb0tCMCAXDTAwMDEwMTAwMDAwMFoYDzMwMDAwMTAx
5+
MDAwMDAwWjBEMRswGQYDVQQKDBJ0cnVzdG1lIHYxLjEuMCtkZXYxJTAjBgNVBAsM
6+
HFRlc3RpbmcgQ0EgI0F1c1VxYlo0bzV3emNvS0IwWTATBgcqhkjOPQIBBggqhkjO
7+
PQMBBwNCAARhrRi78wmZY28t3/y8MTDDCsi7Lzir4WaQm96gf4/9kSolBTFVDUvB
8+
MkSC7Yged+2bWEzTRERZQLf88uiorUnAo0UwQzAdBgNVHQ4EFgQUHymIBJV4gCrA
9+
qv+6Q9pSJFtd7PYwEgYDVR0TAQH/BAgwBgEB/wIBCTAOBgNVHQ8BAf8EBAMCAYYw
10+
CgYIKoZIzj0EAwIDSAAwRQIgLf0sybmdbJoTIgZWrU1k11oecQbdkzh+3jFtNEFn
11+
zYUCIQCRXjIBDZXtyaywk3DgIggByCQxrrB5vjlnyYTd9vNUSw==
12+
-----END CERTIFICATE-----

pytest_httpbin/certs/etc/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

pytest_httpbin/certs/etc/certificate.conf

Lines changed: 0 additions & 18 deletions
This file was deleted.

pytest_httpbin/certs/etc/localhost.crt

Lines changed: 0 additions & 26 deletions
This file was deleted.

pytest_httpbin/certs/etc/localhost.csr

Lines changed: 0 additions & 18 deletions
This file was deleted.

pytest_httpbin/certs/etc/localhost.key

Lines changed: 0 additions & 27 deletions
This file was deleted.

pytest_httpbin/certs/etc/rootCA.crt

Lines changed: 0 additions & 30 deletions
This file was deleted.

pytest_httpbin/certs/etc/rootCA.key

Lines changed: 0 additions & 51 deletions
This file was deleted.

pytest_httpbin/certs/etc/rootCA.srl

Lines changed: 0 additions & 1 deletion
This file was deleted.

pytest_httpbin/certs/key.pem

Lines changed: 0 additions & 27 deletions
This file was deleted.

pytest_httpbin/certs/server.key

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-----BEGIN EC PRIVATE KEY-----
2+
MHcCAQEEIPNMu1H1DN9x0VLZNzO3BFp5boEGyc80XFaR1ML18uFRoAoGCCqGSM49
3+
AwEHoUQDQgAEiNIfYxmsmjemcRRpcd4qP+x1yONFBZZli7CEKxg9j3x5j1OJPeyC
4+
BQ83kogrxJYLbRjdHUx4VOCEXjffmYhnMA==
5+
-----END EC PRIVATE KEY-----

pytest_httpbin/certs/server.pem

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIICTDCCAfOgAwIBAgIUZ9rBQX/YRZFcqXCIzOSAd1D0IUcwCgYIKoZIzj0EAwIw
3+
RDEbMBkGA1UECgwSdHJ1c3RtZSB2MS4xLjArZGV2MSUwIwYDVQQLDBxUZXN0aW5n
4+
IENBICNBdXNVcWJaNG81d3pjb0tCMCAXDTAwMDEwMTAwMDAwMFoYDzMwMDAwMTAx
5+
MDAwMDAwWjBGMRswGQYDVQQKDBJ0cnVzdG1lIHYxLjEuMCtkZXYxJzAlBgNVBAsM
6+
HlRlc3RpbmcgY2VydCAjLVdQNWpjLTllQ0U0S0JxMjBZMBMGByqGSM49AgEGCCqG
7+
SM49AwEHA0IABIjSH2MZrJo3pnEUaXHeKj/sdcjjRQWWZYuwhCsYPY98eY9TiT3s
8+
ggUPN5KIK8SWC20Y3R1MeFTghF4335mIZzCjgb4wgbswHQYDVR0OBBYEFCO99Ega
9+
h7pEyFEJVwe09DZzNHDtMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUHymIBJV4
10+
gCrAqv+6Q9pSJFtd7PYwLwYDVR0RAQH/BCUwI4IJbG9jYWxob3N0hwR/AAABhxAA
11+
AAAAAAAAAAAAAAAAAAABMA4GA1UdDwEB/wQEAwIFoDAqBgNVHSUBAf8EIDAeBggr
12+
BgEFBQcDAgYIKwYBBQUHAwEGCCsGAQUFBwMDMAoGCCqGSM49BAMCA0cAMEQCIHB0
13+
imdD2aQuq4DipTvnFJjmT+w8i3D/Pz8X6bPdkJW/AiATl+m4TW4BE5v1ID3ftDhz
14+
ja8s574nAjDAqcSL7otVpQ==
15+
-----END CERTIFICATE-----

pytest_httpbin/serve.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,29 @@ def get_environ(self):
5252

5353

5454
class SecureWSGIServer(WSGIServer):
55-
def finish_request(self, request, client_address):
56-
"""
57-
Negotiates SSL and then mimics BaseServer behavior.
58-
"""
59-
request.settimeout(1.0)
55+
def get_request(self):
56+
socket, address = super().get_request()
6057
try:
58+
socket.settimeout(1.0)
6159
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
6260
context.load_cert_chain(
63-
os.path.join(CERT_DIR, "cert.pem"),
64-
os.path.join(CERT_DIR, "key.pem"),
61+
os.path.join(CERT_DIR, "server.pem"),
62+
os.path.join(CERT_DIR, "server.key"),
63+
)
64+
return (
65+
context.wrap_socket(
66+
socket, server_side=True, suppress_ragged_eofs=True
67+
),
68+
address,
6569
)
66-
with context.wrap_socket(
67-
request, server_side=True, suppress_ragged_eofs=False
68-
) as ssock:
69-
self.base_environ["HTTPS"] = "yes"
70-
self.RequestHandlerClass(ssock, client_address, self)
7170
except Exception as e:
7271
print("pytest-httpbin server hit an exception serving request: %s" % e)
7372
print("attempting to ignore so the rest of the tests can run")
74-
# WSGIRequestHandler seems to close the socket for us.
75-
# Thanks, WSGIRequestHandler!!
73+
raise
74+
75+
def setup_environ(self):
76+
super().setup_environ()
77+
self.base_environ["HTTPS"] = "yes"
7678

7779

7880
class Server:

0 commit comments

Comments
 (0)