Skip to content

Commit db1c4f3

Browse files
committed
Formatting
1 parent b86c4f8 commit db1c4f3

File tree

9 files changed

+48
-40
lines changed

9 files changed

+48
-40
lines changed

src/stac_auth_proxy/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def configure_app(
4949
**settings_kwargs : Any
5050
Keyword arguments used to configure the health and conformance checks if
5151
``settings`` is not provided.
52+
5253
"""
5354
settings = settings or Settings(**settings_kwargs)
5455

src/stac_auth_proxy/lifespan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ async def check_conformance(
7272
"""Check if the upstream API supports a given conformance class."""
7373
required_conformances: dict[str, list[str]] = {}
7474
for middleware in middleware_classes:
75-
7675
for conformance in getattr(middleware.cls, attr_name, []):
7776
required_conformances.setdefault(conformance, []).append(
7877
middleware.cls.__name__
@@ -127,6 +126,7 @@ def build_lifespan(settings: Settings | None = None, **settings_kwargs: Any):
127126
-------
128127
Callable[[FastAPI], AsyncContextManager[Any]]
129128
A callable suitable for the ``lifespan`` parameter of ``FastAPI``.
129+
130130
"""
131131
if settings is None:
132132
settings = Settings(**settings_kwargs)

src/stac_auth_proxy/utils/cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ def get_value_by_path(obj: dict, path: str, default: Any = None) -> Any:
7878
path: The dot notation path (e.g. "payload.sub")
7979
default: Default value to return if path doesn't exist
8080
81-
Returns
81+
Returns:
8282
-------
8383
The value at the specified path or default if path doesn't exist
84+
8485
"""
8586
try:
8687
for key in path.split("."):

src/stac_auth_proxy/utils/middleware.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def should_transform_response(
2929
Returns
3030
-------
3131
bool: True if the response should be transformed
32+
3233
"""
3334
...
3435

@@ -39,10 +40,12 @@ def transform_json(self, data: Any, request: Request) -> Any:
3940
4041
Args:
4142
data: The parsed JSON data
43+
request: The HTTP request object
4244
43-
Returns
45+
Returns:
4446
-------
4547
The transformed JSON data
48+
4649
"""
4750
...
4851

tests/test_authn.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ def test_with_invalid_tokens_fails(invalid_token, expected_status, source_api_se
312312
)
313313
client = TestClient(test_app)
314314
response = client.get("/collections", headers={"Authorization": invalid_token})
315-
assert (
316-
response.status_code == expected_status
317-
), f"GET request should fail with token: {invalid_token}"
315+
assert response.status_code == expected_status, (
316+
f"GET request should fail with token: {invalid_token}"
317+
)
318318

319319
response = client.options("/collections", headers={"Authorization": invalid_token})
320-
assert (
321-
response.status_code == 200
322-
), f"OPTIONS request should succeed with token: {invalid_token}"
320+
assert response.status_code == 200, (
321+
f"OPTIONS request should succeed with token: {invalid_token}"
322+
)
323323

324324

325325
def test_options_requests_with_cors_headers(source_api_server):
@@ -339,9 +339,9 @@ def test_options_requests_with_cors_headers(source_api_server):
339339
}
340340

341341
response = client.options("/collections", headers=cors_headers)
342-
assert (
343-
response.status_code == 200
344-
), "OPTIONS request with CORS headers should succeed"
342+
assert response.status_code == 200, (
343+
"OPTIONS request with CORS headers should succeed"
344+
)
345345

346346

347347
@pytest.mark.parametrize(

tests/test_filters_jinja2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ async def test_search_post(
188188
"filter-lang": "cql2-json",
189189
}
190190

191-
assert (
192-
proxied_body == expected_output
193-
), "POST query should combine filter expressions."
191+
assert proxied_body == expected_output, (
192+
"POST query should combine filter expressions."
193+
)
194194

195195

196196
@pytest.mark.parametrize(
@@ -241,9 +241,9 @@ async def test_search_get(
241241
),
242242
"filter-lang": filter_lang,
243243
}
244-
assert (
245-
proxied_request.query_params == expected_output
246-
), "GET query should combine filter expressions."
244+
assert proxied_request.query_params == expected_output, (
245+
"GET query should combine filter expressions."
246+
)
247247

248248

249249
@pytest.mark.parametrize(
@@ -444,9 +444,9 @@ async def test_collections_list(
444444
),
445445
"filter-lang": filter_lang,
446446
}
447-
assert (
448-
proxied_request.query_params == expected_output
449-
), "Collections query should combine filter expressions."
447+
assert proxied_request.query_params == expected_output, (
448+
"Collections query should combine filter expressions."
449+
)
450450

451451

452452
@pytest.mark.parametrize(

tests/test_lifespan.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ def test_lifespan_reusable():
8989
"""Ensure the public lifespan handler runs health and conformance checks."""
9090
upstream_url = "https://example.com"
9191
oidc_discovery_url = "https://example.com/.well-known/openid-configuration"
92-
with patch(
93-
"stac_auth_proxy.lifespan.check_server_health",
94-
new=AsyncMock(),
95-
) as mock_health, patch(
96-
"stac_auth_proxy.lifespan.check_conformance",
97-
new=AsyncMock(),
98-
) as mock_conf:
92+
with (
93+
patch(
94+
"stac_auth_proxy.lifespan.check_server_health",
95+
new=AsyncMock(),
96+
) as mock_health,
97+
patch(
98+
"stac_auth_proxy.lifespan.check_conformance",
99+
new=AsyncMock(),
100+
) as mock_conf,
101+
):
99102
app = FastAPI(
100103
lifespan=build_lifespan(
101104
upstream_url=upstream_url,

tests/test_openapi.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ def test_oidc_in_openapi_spec_public_endpoints(
146146
security = config.get("security")
147147

148148
if method == "options":
149-
assert (
150-
not security
151-
), f"OPTIONS {path} requests should not require authentication"
149+
assert not security, (
150+
f"OPTIONS {path} requests should not require authentication"
151+
)
152152
continue
153153

154154
if security:
155-
assert (
156-
path not in expected_required_auth
157-
), f"Path {path} should not require authentication"
155+
assert path not in expected_required_auth, (
156+
f"Path {path} should not require authentication"
157+
)
158158
continue
159159

160-
assert (
161-
path in expected_required_auth
162-
), f"Path {path} should require authentication"
160+
assert path in expected_required_auth, (
161+
f"Path {path} should require authentication"
162+
)
163163
assert any(
164164
method.casefold() == m.casefold() for m in expected_required_auth[path]
165165
)

tests/test_reverse_proxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,6 @@ async def test_nginx_headers_behavior(scope_overrides, headers, expected_forward
279279
# Check that the Forwarded header contains expected values
280280
forwarded = result_headers["Forwarded"]
281281
for key, expected_value in expected_forwarded.items():
282-
assert (
283-
f"{key}={expected_value}" in forwarded
284-
), f"Expected {key}={expected_value} in {forwarded}"
282+
assert f"{key}={expected_value}" in forwarded, (
283+
f"Expected {key}={expected_value} in {forwarded}"
284+
)

0 commit comments

Comments
 (0)