Publish curated ITWorx_MCP_Hub source from 6c7434368ce2a594005983c5a6601a31a639e7f1
This commit is contained in:
1 parent
77946d62c4
commit
6d40ab975c
86 files changed
+6784
-1478
No files matched your search
@@ -4,6 +4,7 @@ from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from packages.hub_clients import ClientKind, generate_config
|
||||
from services.control_api.persistence.db import Base, create_engine_from_url, session_factory
|
||||
from services.control_api.persistence.machine_client import provision_machine_client
|
||||
from services.control_api.persistence.models import (
|
||||
@@ -14,6 +15,7 @@ from services.control_api.persistence.models import (
|
||||
VirtualServerRow,
|
||||
WorkspaceRow,
|
||||
)
|
||||
from services.runtime.client_service import PersistentClientService
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -114,8 +116,19 @@ def test_revoked_machine_client_cannot_be_silently_reactivated(database) -> None
|
||||
_provision(database)
|
||||
|
||||
|
||||
def test_pending_ui_client_is_activated_in_place(database) -> None: # type: ignore[no-untyped-def]
|
||||
@pytest.mark.parametrize("profile", [*ClientKind, None])
|
||||
def test_pending_ui_client_is_activated_in_place_with_selected_profile(
|
||||
database, profile: ClientKind | None
|
||||
) -> None: # type: ignore[no-untyped-def]
|
||||
pending_id = uuid4()
|
||||
expected_profile = profile or ClientKind.STDIO_BRIDGE
|
||||
metadata = {
|
||||
"managedBy": "runtime-onboarding",
|
||||
"project": "ludarium",
|
||||
"environment": "prod",
|
||||
}
|
||||
if profile is not None:
|
||||
metadata["kind"] = profile.value
|
||||
with database() as session, session.begin():
|
||||
workspace = session.query(WorkspaceRow).filter_by(slug="itworx").one()
|
||||
project = session.query(ProjectRow).filter_by(slug="ludarium").one()
|
||||
@@ -127,11 +140,7 @@ def test_pending_ui_client_is_activated_in_place(database) -> None: # type: ign
|
||||
subject=f"pending-{pending_id}",
|
||||
issuer="https://auth.itworx.test/application/o/itworx-mcp-hub/",
|
||||
status="pending",
|
||||
record_metadata={
|
||||
"managedBy": "runtime-onboarding",
|
||||
"project": "ludarium",
|
||||
"environment": "prod",
|
||||
},
|
||||
record_metadata=metadata,
|
||||
)
|
||||
)
|
||||
session.flush()
|
||||
@@ -162,3 +171,55 @@ def test_pending_ui_client_is_activated_in_place(database) -> None: # type: ign
|
||||
assert client.status == "active"
|
||||
assert client.subject == "b7f5d1aa-f199-4334-b077-f6be0870115f"
|
||||
assert binding.enabled is True
|
||||
assert client.record_metadata["kind"] == expected_profile.value
|
||||
assert generate_config(PersistentClientService._record(client)).kind is expected_profile
|
||||
|
||||
|
||||
def test_pending_ui_client_rejects_unknown_profile(database) -> None: # type: ignore[no-untyped-def]
|
||||
pending_id = uuid4()
|
||||
with database() as session, session.begin():
|
||||
workspace = session.query(WorkspaceRow).filter_by(slug="itworx").one()
|
||||
project = session.query(ProjectRow).filter_by(slug="ludarium").one()
|
||||
server = session.query(VirtualServerRow).filter_by(slug="ludarium-prod-readonly").one()
|
||||
session.add(
|
||||
ClientRow(
|
||||
id=pending_id,
|
||||
workspace_id=workspace.id,
|
||||
subject=f"pending-{pending_id}",
|
||||
issuer="https://auth.itworx.test/application/o/itworx-mcp-hub/",
|
||||
status="pending",
|
||||
record_metadata={
|
||||
"managedBy": "runtime-onboarding",
|
||||
"project": "ludarium",
|
||||
"environment": "prod",
|
||||
"kind": "arbitrary-profile",
|
||||
},
|
||||
)
|
||||
)
|
||||
session.flush()
|
||||
session.add(
|
||||
ClientBindingRow(
|
||||
workspace_id=workspace.id,
|
||||
project_id=project.id,
|
||||
client_id=pending_id,
|
||||
virtual_server_id=server.id,
|
||||
enabled=False,
|
||||
)
|
||||
)
|
||||
with database() as session:
|
||||
with pytest.raises(ValueError, match="invalid client kind"):
|
||||
with session.begin():
|
||||
provision_machine_client(
|
||||
session,
|
||||
issuer="https://auth.itworx.test/application/o/itworx-mcp-hub/",
|
||||
subject="b7f5d1aa-f199-4334-b077-f6be0870115f",
|
||||
oauth_username="svc-mcp-codex-ludarium",
|
||||
name="Codex workstation",
|
||||
project_slug="ludarium",
|
||||
client_id=pending_id,
|
||||
)
|
||||
with database() as session:
|
||||
client = session.get(ClientRow, pending_id)
|
||||
assert client is not None
|
||||
assert client.status == "pending"
|
||||
assert client.record_metadata["kind"] == "arbitrary-profile"
|
||||
Reference in new issue
Block a user