Skip to content

Commit 1e17fe2

Browse files
Security - update fastapi to >=0.115.3 (#50)
* Bump fastapi requirement to >= 0.115.3 * Update MockRouter for new pytest-httpx release
1 parent 193dd72 commit 1e17fe2

File tree

8 files changed

+1584
-1925
lines changed

8 files changed

+1584
-1925
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"python.testing.unittestEnabled": false,
2626
"python.testing.pytestEnabled": true,
2727
"editor.codeActionsOnSave": {
28-
"source.organizeImports": true
28+
"source.organizeImports": "explicit"
2929
},
3030
"editor.formatOnSave": true,
3131
"editor.renderWhitespace": "all",
@@ -55,7 +55,8 @@
5555
"visualstudioexptteam.vscodeintellicode",
5656
"ymotongpoo.licenser",
5757
"charliermarsh.ruff",
58-
"ms-python.mypy-type-checker"
58+
"ms-python.mypy-type-checker",
59+
"-ms-python.autopep8"
5960
]
6061
}
6162
},

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
args: [--check]
2323
pass_filenames: false
2424
- repo: https://github.com/pre-commit/pre-commit-hooks
25-
rev: v4.4.0
25+
rev: v5.0.0
2626
hooks:
2727
- id: trailing-whitespace
2828
- id: end-of-file-fixer
@@ -48,13 +48,13 @@ repos:
4848
- id: no-commit-to-branch
4949
args: [--branch, dev, --branch, int, --branch, main]
5050
- repo: https://github.com/astral-sh/ruff-pre-commit
51-
rev: v0.4.4
51+
rev: v0.7.1
5252
hooks:
5353
- id: ruff
5454
args: [--fix, --exit-non-zero-on-fix]
5555
- id: ruff-format
5656
- repo: https://github.com/pre-commit/mirrors-mypy
57-
rev: v1.10.0
57+
rev: v1.13.0
5858
hooks:
5959
- id: mypy
6060
args: [--no-warn-unused-ignores]

.pyproject_generation/pyproject_custom.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ghga_service_commons"
3-
version = "3.1.5"
3+
version = "3.1.6"
44
description = "A library that contains common functionality used in services of GHGA"
55
readme = "README.md"
66
authors = [
@@ -10,7 +10,7 @@ dependencies = ["pydantic >=2, <3"]
1010

1111
[project.optional-dependencies]
1212
api = [
13-
"fastapi>=0.111, <0.112",
13+
"fastapi>=0.115.3, <0.116",
1414
"uvicorn[standard]>=0.29, <0.30",
1515
"ghga-service-commons[objectstorage]",
1616
]

lock/requirements-dev.txt

Lines changed: 895 additions & 1020 deletions
Large diffs are not rendered by default.

lock/requirements.txt

Lines changed: 672 additions & 874 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
"Intended Audience :: Developers",
2424
]
2525
name = "ghga_service_commons"
26-
version = "3.1.5"
26+
version = "3.1.6"
2727
description = "A library that contains common functionality used in services of GHGA"
2828
dependencies = [
2929
"pydantic >=2, <3",
@@ -34,7 +34,7 @@ text = "Apache 2.0"
3434

3535
[project.optional-dependencies]
3636
api = [
37-
"fastapi>=0.111, <0.112",
37+
"fastapi>=0.115.3, <0.116",
3838
"uvicorn[standard]>=0.29, <0.30",
3939
"ghga-service-commons[objectstorage]",
4040
]

src/ghga_service_commons/api/mock_router.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@
2323
from typing import Any, Callable, Generic, TypeVar, cast, get_type_hints
2424

2525
import httpx
26-
import pytest
2726
from pydantic import BaseModel
2827

2928
from ghga_service_commons.httpyexpect.server.exceptions import HttpException
3029

31-
__all__ = [
32-
"MockRouter",
33-
"assert_all_responses_were_requested",
34-
"HttpException",
35-
]
30+
__all__ = ["MockRouter", "HttpException"]
3631

3732
BRACKET_PATTERN = re.compile(r"{.*?}")
3833

@@ -67,17 +62,6 @@ def _get_signature_info(endpoint_function: Callable) -> dict[str, Any]:
6762
return signature_parameters
6863

6964

70-
@pytest.fixture
71-
def assert_all_responses_were_requested() -> bool:
72-
"""Whether httpx checks that all registered responses are sent back.
73-
74-
This is set to false because the registered endpoints are considered mocked even if
75-
they aren't used in a given test. If this is True (default), pytest_httpx will raise
76-
an error if a given test doesn't hit every mocked endpoint.
77-
"""
78-
return False
79-
80-
8165
class RegisteredEndpoint(BaseModel):
8266
"""Endpoint data with the url turned into regex string to get parameters in path."""
8367

tests/integration/test_mock_router.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
from fastapi import HTTPException
2424
from pytest_httpx import HTTPXMock, httpx_mock # noqa: F401
2525

26-
from ghga_service_commons.api.mock_router import ( # noqa: F401
27-
MockRouter,
28-
assert_all_responses_were_requested,
29-
)
26+
from ghga_service_commons.api.mock_router import MockRouter
3027
from ghga_service_commons.httpyexpect.server.exceptions import HttpException
3128
from tests.integration.fixtures.mock_api import app
3229

@@ -85,7 +82,8 @@ def test_get_two_path_variables(httpx_mock: HTTPXMock): # noqa: F811
8582
"""Make sure the handler can parse paths with more than one variable."""
8683
httpx_mock.add_callback(callback=app.handle_request)
8784

88-
expected = ["4", 9] # pass str number as a sanity check that it stays a str
85+
# pass str number as a sanity check that it stays a str
86+
expected = ["4", 9]
8987

9088
with httpx.Client(base_url=BASE_URL) as client:
9189
response = client.get(f"/items/{expected[0]}/sizes/{expected[1]}")
@@ -186,6 +184,9 @@ def dummy(parameter1) -> None:
186184
"""Define a dummy function with missing type-hint info."""
187185

188186

187+
@pytest.mark.httpx_mock(
188+
assert_all_responses_were_requested=False, can_send_already_matched_responses=True
189+
)
189190
def test_handler_errors_filtering(httpx_mock: HTTPXMock): # noqa: F811
190191
"""Make sure only the specified errors are passed to the handler.
191192

0 commit comments

Comments
 (0)