From 94aaab667797580720f89f10ddc54d4401b9f0d7 Mon Sep 17 00:00:00 2001 From: Sean <63349506+SerRichard@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:02:20 +0100 Subject: [PATCH] ensure endpoints are being reported correctly (#62) --- openeo_fastapi/client/core.py | 25 +++++++++++++++++++++++-- pyproject.toml | 2 +- tests/api/test_api.py | 17 ++++++++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/openeo_fastapi/client/core.py b/openeo_fastapi/client/core.py index aeefe14..fc75d52 100644 --- a/openeo_fastapi/client/core.py +++ b/openeo_fastapi/client/core.py @@ -22,7 +22,7 @@ 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 @@ -30,6 +30,25 @@ 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: @@ -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() @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 910e1fc..df96c1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" diff --git a/tests/api/test_api.py b/tests/api/test_api.py index b75e680..8b2c16e 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -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) @@ -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."""