@@ -39,3 +39,35 @@ def test_oidc_in_openapi_spec(source_api: FastAPI, source_api_server: str):
3939 assert "openapi" in openapi
4040 assert "paths" in openapi
4141 assert "oidcAuth" in openapi .get ("components" , {}).get ("securitySchemes" , {})
42+
43+
44+ def test_oidc_in_openapi_spec_private_endpoints (
45+ source_api : FastAPI , source_api_server : str
46+ ):
47+ """When OpenAPI spec endpoint is set & endpoints are marked private, those endpoints are marked private in the spec."""
48+
49+ private_endpoints = {
50+ # https://github.com/stac-api-extensions/collection-transaction/blob/v1.0.0-beta.1/README.md#methods
51+ "/collections" : ["POST" ],
52+ "/collections/{collection_id}" : ["PUT" , "PATCH" , "DELETE" ],
53+ # https://github.com/stac-api-extensions/transaction/blob/v1.0.0-rc.3/README.md#methods
54+ "/collections/{collection_id}/items" : ["POST" ],
55+ "/collections/{collection_id}/items/{item_id}" : ["PUT" , "PATCH" , "DELETE" ],
56+ # https://stac-utils.github.io/stac-fastapi/api/stac_fastapi/extensions/third_party/bulk_transactions/#bulktransactionextension
57+ "/collections/{collection_id}/bulk_items" : ["POST" ],
58+ }
59+ app = app_factory (
60+ upstream_url = source_api_server ,
61+ openapi_spec_endpoint = source_api .openapi_url ,
62+ private_endpoints = private_endpoints ,
63+ )
64+ client = TestClient (app )
65+ openapi = client .get (source_api .openapi_url ).raise_for_status ().json ()
66+ for path , methods in private_endpoints .items ():
67+ for method in methods :
68+ assert "oidcAuth" in (
69+ openapi .get ("paths" , {})
70+ .get (path , {})
71+ .get (method , {})
72+ .get ("security" , [])
73+ )
0 commit comments