Skip to content

Commit

Permalink
add dirac wellknown metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertrand Rigaud committed Oct 20, 2023
1 parent 39a73bb commit fa6a463
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/diracx/cli/internal/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/diracx/core/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/diracx/routers/well_known.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import Any

from fastapi import Request

from diracx.routers.auth import AuthSettings
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/cli/legacy/cs_sync/integration_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,7 @@ Registry
#@@-prod - /C=ch/O=DIRAC/OU=DIRAC CI/CN=ciuser - 2023-10-02 12:36:08
Jenkins
{
SupportMessage = contact [email protected]
#@@-prod - /C=ch/O=DIRAC/OU=DIRAC CI/CN=ciuser - 2023-10-02 12:36:08
VOMSName = myVOMS
}
Expand Down
1 change: 1 addition & 0 deletions tests/cli/legacy/cs_sync/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Registry:
IdP:
ClientID: 995ed3b9-d5bd-49d3-a7f4-7fc7dbd5a0cd
URL: https://jenkins.invalid/
SupportMessage: "contact [email protected]"
Users:
26dbe36e-cf5c-4c52-a834-29a1c904ef74:
Email: [email protected]
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/legacy/cs_sync/test_cssync.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typer.testing import CliRunner

from diracx.cli import app
from diracx.core.config.schema import Config

runner = CliRunner()

Expand All @@ -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)
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def with_config_repo(tmp_path):
"Registry": {
"lhcb": {
"DefaultGroup": "lhcb_user",
"SupportMessage": "Please contact administrator",
"DefaultProxyLifeTime": 432000,
"DefaultStorageQuota": 2000,
"IdP": {
Expand Down
7 changes: 7 additions & 0 deletions tests/routers/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit fa6a463

Please sign in to comment.