Skip to content

Commit

Permalink
ensure endpoints are being reported correctly (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
SerRichard authored Nov 19, 2024
1 parent bd1e453 commit 94aaab6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
25 changes: 23 additions & 2 deletions openeo_fastapi/client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,33 @@
UdfRuntimesGetResponse,
WellKnownOpeneoGetResponse,
)
from openeo_fastapi.api.types import Error, STACConformanceClasses, Version
from openeo_fastapi.api.types import Endpoint, Error, STACConformanceClasses, Version
from openeo_fastapi.client.auth import Authenticator, User
from openeo_fastapi.client.collections import CollectionRegister
from openeo_fastapi.client.files import FilesRegister
from openeo_fastapi.client.jobs import JobsRegister
from openeo_fastapi.client.processes import ProcessRegister
from openeo_fastapi.client.settings import AppSettings

APPLICATION_ENDPOINTS = [
Endpoint(
path="/",
methods=["GET"],
),
Endpoint(
path="/.well-known/openeo",
methods=["GET"],
),
Endpoint(
path="/conformance",
methods=["GET"],
),
Endpoint(
path="/credentials/oidc",
methods=["GET"],
),
]


@define
class OpenEOCore:
Expand All @@ -49,6 +68,8 @@ class OpenEOCore:
jobs: Optional[JobsRegister] = None
processes: Optional[ProcessRegister] = None

endpoints = APPLICATION_ENDPOINTS

def __attrs_post_init__(self):
"""Post init hook to set the client registers, if none where provided by the user set to the defaults!"""
self.settings = AppSettings()
Expand All @@ -66,7 +87,7 @@ def _combine_endpoints(self):
"""
registers = [self.collections, self.files, self.jobs, self.processes]

endpoints = []
endpoints = self.endpoints
for register in registers:
if register:
endpoints.extend(register.endpoints)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openeo-fastapi"
version = "2024.11.1"
version = "2024.11.2"
description = "FastApi implementation conforming to the OpenEO Api specification."
authors = ["Sean Hoyal <sean.hoyal@external.eodc.eu>"]
readme = "README.md"
Expand Down
17 changes: 16 additions & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_policies_set(app_settings):
assert len(app_settings.OIDC_POLICIES) == 1


def test_get_wellknown(core_api, app_settings):
def test_get_wellknown(core_api):
"""Test the OpenEOApi and OpenEOCore classes interact as intended."""

test_app = TestClient(core_api.app)
Expand All @@ -54,6 +54,21 @@ def test_get_capabilities(core_api, app_settings):
assert response.status_code == 200
assert response.json()["title"] == "Test Api"

found_oidc = False
found_conformance = False
found_wellknown = False
for endpoint in response.json()["endpoints"]:
if endpoint["path"] == "/credentials/oidc":
found_oidc = True
elif endpoint["path"] == "/conformance":
found_conformance = True
elif endpoint["path"] == "/.well-known/openeo":
found_wellknown = True
if found_oidc & found_conformance & found_wellknown:
break

assert found_oidc & found_conformance & found_wellknown


def test_get_credentials_oidc(core_api, app_settings):
"""Test the OpenEOApi and OpenEOCore classes interact as intended."""
Expand Down

0 comments on commit 94aaab6

Please sign in to comment.