fix: reject mismatched capability inspection
This commit is contained in:
@@ -94,6 +94,14 @@ class App:
|
|||||||
await self._port.inspect_capability(qualified_name=name)
|
await self._port.inspect_capability(qualified_name=name)
|
||||||
)
|
)
|
||||||
qualified_name = wire["name"]
|
qualified_name = wire["name"]
|
||||||
|
if qualified_name != name:
|
||||||
|
raise InvalidResponse(
|
||||||
|
operation="workflow.capabilities.inspect",
|
||||||
|
details=(
|
||||||
|
f"inspected capability {qualified_name!r} does not match "
|
||||||
|
f"requested {name!r}"
|
||||||
|
),
|
||||||
|
)
|
||||||
source_id = wire["source_id"]
|
source_id = wire["source_id"]
|
||||||
return RemoteCapability(
|
return RemoteCapability(
|
||||||
_port=self._port,
|
_port=self._port,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import httpx
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from wf_client import App, CapabilitySummary, Page
|
from wf_client import App, CapabilitySummary, Page
|
||||||
|
from wf_client.errors import InvalidResponse
|
||||||
from wf_client.protocols import WorkflowClientPort
|
from wf_client.protocols import WorkflowClientPort
|
||||||
from wf_platform import CapabilityRef
|
from wf_platform import CapabilityRef
|
||||||
|
|
||||||
@@ -119,3 +120,11 @@ async def test_capability_reference_keeps_dotted_local_key() -> None:
|
|||||||
|
|
||||||
assert capability.ref.source.parts == ("app", "default")
|
assert capability.ref.source.parts == ("app", "default")
|
||||||
assert capability.ref.name == "search.v2"
|
assert capability.ref.name == "search.v2"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_capability_rejects_mismatched_inspection_name() -> None:
|
||||||
|
app = _app(capability_name="app.default.other")
|
||||||
|
|
||||||
|
with pytest.raises(InvalidResponse, match="workflow.capabilities.inspect"):
|
||||||
|
await app.capability("app.default.search")
|
||||||
|
|||||||
Reference in New Issue
Block a user