diff --git a/src/diracx/cli/internal/legacy.py b/src/diracx/cli/internal/legacy.py index f7cefea92..1788497f5 100644 --- a/src/diracx/cli/internal/legacy.py +++ b/src/diracx/cli/internal/legacy.py @@ -106,6 +106,12 @@ def _apply_fixes(raw, conversion_config: Path): "Users": {}, "Groups": {}, } + + support_message = ( + original_registry.get("VO", {}).get(vo, {}).get("SupportMessage") + ) + if support_message: + raw["Registry"][vo]["SupportMessage"] = support_message if "DefaultStorageQuota" in original_registry: raw["Registry"][vo]["DefaultStorageQuota"] = original_registry[ "DefaultStorageQuota" diff --git a/src/diracx/core/config/schema.py b/src/diracx/core/config/schema.py index e7b78b5ea..71da38d6a 100644 --- a/src/diracx/core/config/schema.py +++ b/src/diracx/core/config/schema.py @@ -69,6 +69,7 @@ def server_metadata_url(self): class RegistryConfig(BaseModel): IdP: IdpConfig + SupportMessage: str = "Please contact system administrator" DefaultGroup: str DefaultStorageQuota: float = 0 DefaultProxyLifeTime: int = 12 * 60 * 60 diff --git a/src/diracx/routers/well_known.py b/src/diracx/routers/well_known.py index 9f7b93f1f..f706f0576 100644 --- a/src/diracx/routers/well_known.py +++ b/src/diracx/routers/well_known.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import Any + from fastapi import Request from diracx.routers.auth import AuthSettings @@ -40,3 +42,27 @@ async def openid_configuration( "token_endpoint_auth_methods_supported": ["none"], "code_challenge_methods_supported": ["S256"], } + + +@router.get("/dirac") +async def dirac_configuration( + config: Config, +): + vos: dict[str, Any] = {} + vos["virtual_organisations"] = [] + for vo in config.Registry: + infos: dict[str, Any] = {} + infos[vo] = {} + infos[vo]["groups"] = {} + for g in config.Registry[vo].Groups: + infos[vo]["groups"][g] = {} + infos[vo]["groups"][g]["properties"] = sorted( + config.Registry[vo].Groups[g].Properties + ) + + infos[vo]["SupportMessage"] = config.Registry[vo].SupportMessage + infos[vo]["default_group"] = config.Registry[vo].DefaultGroup + + vos["virtual_organisations"].append(infos) + + return vos diff --git a/tests/cli/legacy/cs_sync/integration_test.cfg b/tests/cli/legacy/cs_sync/integration_test.cfg index d1da5b17a..25c5fa008 100644 --- a/tests/cli/legacy/cs_sync/integration_test.cfg +++ b/tests/cli/legacy/cs_sync/integration_test.cfg @@ -1451,6 +1451,7 @@ Registry #@@-prod - /C=ch/O=DIRAC/OU=DIRAC CI/CN=ciuser - 2023-10-02 12:36:08 Jenkins { + SupportMessage = contact tata@yoyo.fr #@@-prod - /C=ch/O=DIRAC/OU=DIRAC CI/CN=ciuser - 2023-10-02 12:36:08 VOMSName = myVOMS } diff --git a/tests/cli/legacy/cs_sync/integration_test.yaml b/tests/cli/legacy/cs_sync/integration_test.yaml index ec54e3343..50f6204c7 100644 --- a/tests/cli/legacy/cs_sync/integration_test.yaml +++ b/tests/cli/legacy/cs_sync/integration_test.yaml @@ -69,6 +69,7 @@ Registry: IdP: ClientID: 995ed3b9-d5bd-49d3-a7f4-7fc7dbd5a0cd URL: https://jenkins.invalid/ + SupportMessage: "contact tata@yoyo.fr" Users: 26dbe36e-cf5c-4c52-a834-29a1c904ef74: Email: lhcb-dirac-ci@cern.ch diff --git a/tests/cli/legacy/cs_sync/test_cssync.py b/tests/cli/legacy/cs_sync/test_cssync.py index 4cfa179a5..3c3c5a221 100644 --- a/tests/cli/legacy/cs_sync/test_cssync.py +++ b/tests/cli/legacy/cs_sync/test_cssync.py @@ -4,6 +4,7 @@ from typer.testing import CliRunner from diracx.cli import app +from diracx.core.config.schema import Config runner = CliRunner() @@ -28,7 +29,7 @@ def test_cs_sync(tmp_path, monkeypatch): ) assert result.exit_code == 0 assert output_file.is_file() - actual_output = yaml.safe_load(output_file.read_text()) expected_output = yaml.safe_load((file_path / "integration_test.yaml").read_text()) assert actual_output == expected_output + Config.parse_obj(actual_output) diff --git a/tests/conftest.py b/tests/conftest.py index 6a067074f..9db3e055c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -169,6 +169,7 @@ def with_config_repo(tmp_path): "Registry": { "lhcb": { "DefaultGroup": "lhcb_user", + "SupportMessage": "Please contact administrator", "DefaultProxyLifeTime": 432000, "DefaultStorageQuota": 2000, "IdP": { diff --git a/tests/routers/test_generic.py b/tests/routers/test_generic.py index d34b12cd1..6535bee87 100644 --- a/tests/routers/test_generic.py +++ b/tests/routers/test_generic.py @@ -8,3 +8,10 @@ def test_oidc_configuration(test_client): r = test_client.get("/.well-known/openid-configuration") assert r.status_code == 200 assert r.json() + + +def test_dirac_configuration(test_client): + r = test_client.get("/.well-known/dirac") + + assert r.status_code == 200 + assert r.json()