[Server] Add ClientGateway::supportsSampling() (#418)
Sampling was the one client capability a tool could not check before asking. `supportsRoots()` and `supportsElicitation()` both read the capabilities the client advertised during the handshake; sampling is stored in that same session data but had no accessor, so a tool had to issue the request and catch the refusal.
This commit is contained in:
parent
eb20453f49
commit
c4b163b4c4
1 changed files with 38 additions and 0 deletions
|
|
@ -43,6 +43,26 @@ final class ClientGatewayTest extends TestCase
|
|||
$this->assertFalse($gateway->supportsRoots());
|
||||
}
|
||||
|
||||
public function testSupportsSamplingReturnsTrueWhenAdvertised(): void
|
||||
{
|
||||
$session = $this->createMock(SessionInterface::class);
|
||||
$session->method('get')->with('client_capabilities', [])->willReturn(['sampling' => []]);
|
||||
|
||||
$gateway = new ClientGateway($session);
|
||||
|
||||
$this->assertTrue($gateway->supportsSampling());
|
||||
}
|
||||
|
||||
public function testSupportsSamplingReturnsFalseWhenNotAdvertised(): void
|
||||
{
|
||||
$session = $this->createMock(SessionInterface::class);
|
||||
$session->method('get')->with('client_capabilities', [])->willReturn(['roots' => []]);
|
||||
|
||||
$gateway = new ClientGateway($session);
|
||||
|
||||
$this->assertFalse($gateway->supportsSampling());
|
||||
}
|
||||
|
||||
public function testListRootsReturnsRootsFromClient(): void
|
||||
{
|
||||
$session = $this->createMock(SessionInterface::class);
|
||||
|
|
|
|||
Loading…
Reference in a new issue