diff --git a/diracx-cli/pyproject.toml b/diracx-cli/pyproject.toml index 166b034c..d33abfb6 100644 --- a/diracx-cli/pyproject.toml +++ b/diracx-cli/pyproject.toml @@ -67,3 +67,4 @@ asyncio_mode = "auto" markers = [ "enabled_dependencies: List of dependencies which should be available to the FastAPI test client", ] +asyncio_default_fixture_loop_scope = "session" diff --git a/diracx-client/src/diracx/client/extensions.py b/diracx-client/src/diracx/client/extensions.py index 0734698a..3379573e 100644 --- a/diracx-client/src/diracx/client/extensions.py +++ b/diracx-client/src/diracx/client/extensions.py @@ -12,28 +12,10 @@ class DiracxLoader(SourceFileLoader): def create_module(self, spec): - print(f"CHRIS I LOAD !!!! {spec=}", flush=True) if spec.name in sys.modules: - print("CHRIS ALREAY DEFINED") return sys.modules[spec.name] - # breakpoint() - print(f"CHRIS HAVE TO CALL SUPER", flush=True) - # return super().create_module(spec) - # try to read txt file content - try: - with open(self.filepath) as inp_file: - self.data = inp_file.read() - except: - # raise ImportError if there was an error loading the file - raise ImportError - # when returning None, default module creation will be called - - def exec_module(self, module): - print("CHRIS EXEC ", flush=True) - # breakpoint() - - # here we update module and add our custom members - # module.__dict__.update({"data": self.data}) + + def exec_module(self, module): ... class DiracxPathFinder(MetaPathFinder): @@ -59,18 +41,12 @@ def find_spec(cls, fullname, path, target=None): ] ] ): - if "client.generated.models._patch" in fullname: - - print(f"CHRIS find_spec {fullname=} {path=}") for lower_extension in cls.diracx_extensions[i:][::-1]: try: patched_name = fullname.replace(extension, lower_extension) # breakpoint() overwritten = importlib.util.find_spec(patched_name) - print( - f"CHRIS patching {fullname=} {patched_name=} {overwritten}", - flush=True, - ) + spec = ModuleSpec( patched_name, DiracxLoader(patched_name, path) ) diff --git a/diracx-db/src/diracx/db/__main__.py b/diracx-db/src/diracx/db/__main__.py index da36eace..179da9b7 100644 --- a/diracx-db/src/diracx/db/__main__.py +++ b/diracx-db/src/diracx/db/__main__.py @@ -31,6 +31,7 @@ async def init_sql(): from diracx.db.sql.utils import BaseSQLDB for db_name, db_url in BaseSQLDB.available_urls().items(): + logger.info("Initialising %s", db_name) db = BaseSQLDB.available_implementations(db_name)[0](db_url) async with db.engine_context(): diff --git a/diracx-routers/pyproject.toml b/diracx-routers/pyproject.toml index 4a8f49e4..b740836b 100644 --- a/diracx-routers/pyproject.toml +++ b/diracx-routers/pyproject.toml @@ -79,7 +79,9 @@ addopts = [ "--import-mode=importlib", ] asyncio_mode = "auto" -asyncio_default_fixture_loop_scope = "session" markers = [ "enabled_dependencies: List of dependencies which should be available to the FastAPI test client", ] + + +asyncio_default_fixture_loop_scope = "function" diff --git a/extensions/gubbins/gubbins-cli/tests/test_gubbins_cli.py b/extensions/gubbins/gubbins-cli/tests/test_gubbins_cli.py index 50e53425..56da978a 100644 --- a/extensions/gubbins/gubbins-cli/tests/test_gubbins_cli.py +++ b/extensions/gubbins/gubbins-cli/tests/test_gubbins_cli.py @@ -6,13 +6,19 @@ runner = CliRunner() -async def test_lollygag_hello(): +def test_lollygag_cli(): result = runner.invoke(app, ["--help"], env=os.environ) assert result.exit_code == 0, result.output assert "lollygag" in result.output, result.output -async def test_lollygag_owner(with_cli_login): +def test_lollygag_hello(with_cli_login): result = runner.invoke(app, ["lollygag", "hello"], env=os.environ) assert result.exit_code == 0, result.output assert "Baby" in result.output, result.output + + +def test_lollygag_owner(with_cli_login): + result = runner.invoke(app, ["lollygag", "get-owners"], env=os.environ) + assert result.exit_code == 0, result.output + assert "[]" in result.output, result.output diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/__init__.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/__init__.py index 2c8c7f02..155f03af 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/__init__.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_client.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_client.py index f596c028..e5ad9e7b 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_client.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_configuration.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_configuration.py index 0025bd45..5aeb4b08 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_configuration.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_vendor.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_vendor.py index 48fde78e..da19d4e6 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_vendor.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/__init__.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/__init__.py index 2c8c7f02..155f03af 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/__init__.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_client.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_client.py index 09738239..d9671550 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_client.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_configuration.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_configuration.py index f88426f4..688de977 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_configuration.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_configuration.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_vendor.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_vendor.py index 48fde78e..da19d4e6 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_vendor.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/_vendor.py @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/__init__.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/__init__.py index dbd5e109..e6ddd7aa 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/__init__.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/_operations.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/_operations.py index 1ab534a8..7cca6ddc 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/_operations.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/aio/operations/_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -152,13 +152,13 @@ async def openid_configuration(self, **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace_async - async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: + async def installation_metadata(self, **kwargs: Any) -> _models.ExtendedMetadata: """Installation Metadata. Installation Metadata. - :return: Metadata - :rtype: ~generated.models.Metadata + :return: ExtendedMetadata + :rtype: ~generated.models.ExtendedMetadata :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -172,7 +172,7 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Metadata] = kwargs.pop("cls", None) + cls: ClsType[_models.ExtendedMetadata] = kwargs.pop("cls", None) _request = build_well_known_installation_metadata_request( headers=_headers, @@ -195,7 +195,9 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("Metadata", pipeline_response.http_response) + deserialized = self._deserialize( + "ExtendedMetadata", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/__init__.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/__init__.py index 148094b5..636be90e 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/__init__.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/__init__.py @@ -1,12 +1,13 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._models import BodyAuthToken from ._models import BodyAuthTokenGrantType from ._models import DevelopmentSettings +from ._models import ExtendedMetadata from ._models import GroupInfo from ._models import HTTPValidationError from ._models import InitiateDeviceFlowResponse @@ -18,7 +19,6 @@ from ._models import JobSummaryParams from ._models import JobSummaryParamsSearchItem from ._models import LimitedJobStatusReturn -from ._models import Metadata from ._models import SandboxDownloadResponse from ._models import SandboxInfo from ._models import SandboxUploadResponse @@ -55,6 +55,7 @@ "BodyAuthToken", "BodyAuthTokenGrantType", "DevelopmentSettings", + "ExtendedMetadata", "GroupInfo", "HTTPValidationError", "InitiateDeviceFlowResponse", @@ -66,7 +67,6 @@ "JobSummaryParams", "JobSummaryParamsSearchItem", "LimitedJobStatusReturn", - "Metadata", "SandboxDownloadResponse", "SandboxInfo", "SandboxUploadResponse", diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_enums.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_enums.py index 9668061c..0f0aaa4b 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_enums.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_enums.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_models.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_models.py index b1d63919..a914df92 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_models.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/models/_models.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -126,6 +126,58 @@ def __init__( self.crash_on_missed_access_policy = crash_on_missed_access_policy +class ExtendedMetadata(_serialization.Model): + """ExtendedMetadata. + + All required parameters must be populated in order to send to server. + + :ivar virtual_organizations: Virtual Organizations. Required. + :vartype virtual_organizations: dict[str, ~generated.models.VOInfo] + :ivar development_settings: Settings for the Development Configuration that can influence run + time. Required. + :vartype development_settings: ~generated.models.DevelopmentSettings + :ivar gubbins_secrets: Gubbins Secrets. Required. + :vartype gubbins_secrets: str + """ + + _validation = { + "virtual_organizations": {"required": True}, + "development_settings": {"required": True}, + "gubbins_secrets": {"required": True}, + } + + _attribute_map = { + "virtual_organizations": {"key": "virtual_organizations", "type": "{VOInfo}"}, + "development_settings": { + "key": "development_settings", + "type": "DevelopmentSettings", + }, + "gubbins_secrets": {"key": "gubbins_secrets", "type": "str"}, + } + + def __init__( + self, + *, + virtual_organizations: Dict[str, "_models.VOInfo"], + development_settings: "_models.DevelopmentSettings", + gubbins_secrets: str, + **kwargs: Any, + ) -> None: + """ + :keyword virtual_organizations: Virtual Organizations. Required. + :paramtype virtual_organizations: dict[str, ~generated.models.VOInfo] + :keyword development_settings: Settings for the Development Configuration that can influence + run time. Required. + :paramtype development_settings: ~generated.models.DevelopmentSettings + :keyword gubbins_secrets: Gubbins Secrets. Required. + :paramtype gubbins_secrets: str + """ + super().__init__(**kwargs) + self.virtual_organizations = virtual_organizations + self.development_settings = development_settings + self.gubbins_secrets = gubbins_secrets + + class GroupInfo(_serialization.Model): """GroupInfo. @@ -555,50 +607,6 @@ def __init__( self.application_status = application_status -class Metadata(_serialization.Model): - """Metadata. - - All required parameters must be populated in order to send to server. - - :ivar virtual_organizations: Virtual Organizations. Required. - :vartype virtual_organizations: dict[str, ~generated.models.VOInfo] - :ivar development_settings: Settings for the Development Configuration that can influence run - time. Required. - :vartype development_settings: ~generated.models.DevelopmentSettings - """ - - _validation = { - "virtual_organizations": {"required": True}, - "development_settings": {"required": True}, - } - - _attribute_map = { - "virtual_organizations": {"key": "virtual_organizations", "type": "{VOInfo}"}, - "development_settings": { - "key": "development_settings", - "type": "DevelopmentSettings", - }, - } - - def __init__( - self, - *, - virtual_organizations: Dict[str, "_models.VOInfo"], - development_settings: "_models.DevelopmentSettings", - **kwargs: Any, - ) -> None: - """ - :keyword virtual_organizations: Virtual Organizations. Required. - :paramtype virtual_organizations: dict[str, ~generated.models.VOInfo] - :keyword development_settings: Settings for the Development Configuration that can influence - run time. Required. - :paramtype development_settings: ~generated.models.DevelopmentSettings - """ - super().__init__(**kwargs) - self.virtual_organizations = virtual_organizations - self.development_settings = development_settings - - class SandboxDownloadResponse(_serialization.Model): """SandboxDownloadResponse. diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/__init__.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/__init__.py index dbd5e109..e6ddd7aa 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/__init__.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/_operations.py b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/_operations.py index 79fb56a4..87d78c95 100644 --- a/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/_operations.py +++ b/extensions/gubbins/gubbins-client/src/gubbins/client/generated/operations/_operations.py @@ -1,7 +1,7 @@ # pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.25.0) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/python@6.25.0) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -1009,13 +1009,13 @@ def openid_configuration(self, **kwargs: Any) -> Any: return deserialized # type: ignore @distributed_trace - def installation_metadata(self, **kwargs: Any) -> _models.Metadata: + def installation_metadata(self, **kwargs: Any) -> _models.ExtendedMetadata: """Installation Metadata. Installation Metadata. - :return: Metadata - :rtype: ~generated.models.Metadata + :return: ExtendedMetadata + :rtype: ~generated.models.ExtendedMetadata :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1029,7 +1029,7 @@ def installation_metadata(self, **kwargs: Any) -> _models.Metadata: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Metadata] = kwargs.pop("cls", None) + cls: ClsType[_models.ExtendedMetadata] = kwargs.pop("cls", None) _request = build_well_known_installation_metadata_request( headers=_headers, @@ -1052,7 +1052,9 @@ def installation_metadata(self, **kwargs: Any) -> _models.Metadata: ) raise HttpResponseError(response=response) - deserialized = self._deserialize("Metadata", pipeline_response.http_response) + deserialized = self._deserialize( + "ExtendedMetadata", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/extensions/gubbins/gubbins-routers/src/gubbins/routers/well_known.py b/extensions/gubbins/gubbins-routers/src/gubbins/routers/well_known.py index b160f020..6e2c9915 100644 --- a/extensions/gubbins/gubbins-routers/src/gubbins/routers/well_known.py +++ b/extensions/gubbins/gubbins-routers/src/gubbins/routers/well_known.py @@ -1,8 +1,10 @@ from diracx.routers.auth.well_known import Metadata +from diracx.routers.auth.well_known import ( + installation_metadata as _installation_metadata, +) from diracx.routers.auth.well_known import router as diracx_wellknown_router from diracx.routers.dependencies import Config, DevelopmentSettings from diracx.routers.fastapi_classes import DiracxRouter -from fastapi import HTTPException, status router = DiracxRouter(require_auth=False, path_root="") router.include_router(diracx_wellknown_router) @@ -10,13 +12,22 @@ # Just overriding does not work: https://github.com/tiangolo/fastapi/discussions/8489 +# Change slightly the return type +class ExtendedMetadata(Metadata): + gubbins_secrets: str + + +# Overwrite the dirac-metadata endpoint and add an extra metadata @router.get("/dirac-metadata") async def installation_metadata( config: Config, # check_permissions: OpenAccessPolicyCallable, dev_settings: DevelopmentSettings, -) -> Metadata: - raise HTTPException( - status_code=status.HTTP_400_BAD_REQUEST, - detail="Device flow in forbidden in gubbins", +) -> ExtendedMetadata: + original_metadata = await _installation_metadata(config, dev_settings) + gubbins_metadata = ExtendedMetadata( + gubbins_secrets="hush!", + virtual_organizations=original_metadata.virtual_organizations, + development_settings=original_metadata.development_settings, ) + return gubbins_metadata diff --git a/extensions/gubbins/gubbins-routers/tests/test_wellknown.py b/extensions/gubbins/gubbins-routers/tests/test_wellknown.py index 104bb022..cc4aef50 100644 --- a/extensions/gubbins/gubbins-routers/tests/test_wellknown.py +++ b/extensions/gubbins/gubbins-routers/tests/test_wellknown.py @@ -16,7 +16,8 @@ async def test_dirac_metadata_is_overwriten(test_client): r = test_client.get( "/.well-known/dirac-metadata", ) - assert r.status_code == 400, r.json() + assert r.status_code == 200, r.json() + assert "gubbins_secrets" in r.json(), r.json() async def test_openid_configuration_is_not_changed(test_client):