Visitar URL original
Merge pull request #138 from NHSDigital/mesh-2092-dependabot-combined · NHSDigital/mesh-client@3e30944 · GitHub
Skip to content

Commit 3e30944

Browse files
Merge pull request #138 from NHSDigital/mesh-2092-dependabot-combined
MESH-2092 Combined Dependabot PRs
2 parents 23e1730 + 156c98c commit 3e30944

9 files changed

Lines changed: 438 additions & 146 deletions

File tree

‎.github/workflows/merge-develop.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383

8484
- name: publish junit reports
8585
if: success() || failure()
86-
uses: mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6
86+
uses: mikepenz/action-junit-report@a294a61c909bd8a4b563024a2faa28897fd53ebc
8787
with:
8888
check_name: junit reports
8989
report_paths: reports/junit/*.xml

‎.github/workflows/pull-request.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ jobs:
169169

170170
- name: archive reports
171171
if: github.actor != 'dependabot[bot]' && (success() || failure())
172-
uses: actions/upload-artifact@v5
172+
uses: actions/upload-artifact@v6
173173
with:
174174
name: reports
175175
path: reports/**/*
176176

177177
- name: publish junit reports
178178
if: success() || failure()
179-
uses: mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6
179+
uses: mikepenz/action-junit-report@a294a61c909bd8a4b563024a2faa28897fd53ebc
180180
with:
181181
check_name: junit reports
182182
report_paths: reports/junit/*.xml

‎.vscode/settings.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"."
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

‎mesh_client/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def create_ssl_context(self) -> ssl.SSLContext:
261261

262262
context.minimum_version = ssl.TLSVersion.TLSv1_2
263263

264-
if self.cert and isinstance(self.cert, (tuple, list)):
264+
if self.cert and isinstance(self.cert, tuple | list):
265265
context.load_cert_chain(*self.cert)
266266

267267
if self.verify:
268-
if isinstance(self.verify, (str, bytes)):
268+
if isinstance(self.verify, str | bytes):
269269
context.load_verify_locations(self.verify)
270270

271271
if self.check_hostname is not None:

‎poetry.lock‎

Lines changed: 139 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ requests = ">=2.32.0,<3.0.0"
3232
werkzeug = ">=3.0.3,<4.0.0"
3333

3434
[tool.poetry.group.dev.dependencies]
35-
black = "^25"
35+
black = ">=25,<27"
3636
mypy = "^1.4.1"
3737
types-six = "^1.16.21.8"
3838
types-requests = "^2.31.0.1"
@@ -43,7 +43,7 @@ toml = "^0.10.2"
4343
tox = "^4.6.3"
4444
types-setuptools = "^80"
4545
coverage = "^7.2.7"
46-
pytest = ">=7.4,<9.0"
46+
pytest = ">=7.4,<10.0"
4747
importlib-metadata = {version = ">=4.11.4", python = "<3.12"}
4848
pytest-httpserver = "^1.0.8"
4949
ruff = "^0"

‎requirements.txt‎

Lines changed: 219 additions & 0 deletions
Large diffs are not rendered by default.

‎setup.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
this shim is required ... because the PyPI package name contains upper case chars . and pyproject.toml
44
will lowercase under PEP-518 build systems.
55
"""
6+
67
import os
78
from os.path import dirname, join
89

‎tests/ssl_context_adapter_tests.py‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from __future__ import annotations
2+
3+
from unittest.mock import Mock
4+
5+
import pytest
6+
7+
import mesh_client
8+
9+
10+
class SSLContextStub:
11+
def __init__(self) -> None:
12+
self.load_cert_chain = Mock()
13+
self.load_verify_locations = Mock()
14+
self.minimum_version = None
15+
self.check_hostname = None
16+
self.verify_mode = None
17+
self.hostname_checks_common_name = None
18+
19+
20+
@pytest.mark.parametrize(
21+
("certs", "loads_cert_chain_called"),
22+
[
23+
(("client.crt", "client.key"), True),
24+
(None, False),
25+
(["client.crt", "client.key"], True),
26+
],
27+
)
28+
def test_create_ssl_context_loads_cert_chain(
29+
monkeypatch, certs: tuple[str, str] | list[str] | None, loads_cert_chain_called: bool
30+
):
31+
32+
dummy_context = SSLContextStub()
33+
monkeypatch.setattr(mesh_client, "create_urllib3_context", lambda: dummy_context)
34+
35+
adapter = mesh_client.SSLContextAdapter(cert=certs, verify=None) # type: ignore[arg-type]
36+
dummy_context.load_cert_chain.reset_mock()
37+
38+
context = adapter.create_ssl_context()
39+
40+
assert context is dummy_context
41+
42+
if loads_cert_chain_called:
43+
assert certs is not None
44+
dummy_context.load_cert_chain.assert_called_with(*certs)
45+
else:
46+
dummy_context.load_cert_chain.assert_not_called()
47+
48+
49+
@pytest.mark.parametrize("verify", [True, False, "/path/to/ca.pem", b"/path/to/ca.pem", None])
50+
def test_create_ssl_context_loads_verify_locations_when_verify_is_provided(
51+
monkeypatch, verify: bool | str | bytes | None
52+
):
53+
54+
dummy_context = SSLContextStub()
55+
monkeypatch.setattr(mesh_client, "create_urllib3_context", lambda: dummy_context)
56+
57+
adapter = mesh_client.SSLContextAdapter(cert=None, verify=verify) # type: ignore[arg-type]
58+
context = adapter.create_ssl_context()
59+
60+
assert context is dummy_context
61+
62+
if type(verify) in (str, bytes):
63+
dummy_context.load_verify_locations.assert_called_with(verify)
64+
else:
65+
dummy_context.load_verify_locations.assert_not_called()

0 commit comments

Comments
 (0)