mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 12:39:24 -07:00
feat(elicitation): raise CredentialsNotConfiguredError in client when creds absent
make_graphql_request now reads credentials from the settings module at call time (via a local import) instead of relying on module-level names captured at import time. When either credential is missing it raises CredentialsNotConfiguredError (not ToolError), allowing callers to trigger elicitation rather than surfacing a generic error to the MCP client. Updated tests/test_client.py and tests/http_layer/test_request_construction.py to patch unraid_mcp.config.settings.* instead of the now-removed client-module attrs, and to expect CredentialsNotConfiguredError on missing credentials.
This commit is contained in:
@@ -154,3 +154,23 @@ async def test_elicit_and_configure_returns_false_on_cancel():
|
||||
|
||||
result = await elicit_and_configure(mock_ctx)
|
||||
assert result is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_graphql_request_raises_sentinel_when_unconfigured():
|
||||
"""make_graphql_request raises CredentialsNotConfiguredError (not ToolError) when
|
||||
credentials are absent, so callers can trigger elicitation."""
|
||||
from unraid_mcp.config import settings as settings_mod
|
||||
from unraid_mcp.core.client import make_graphql_request
|
||||
from unraid_mcp.core.exceptions import CredentialsNotConfiguredError
|
||||
|
||||
original_url = settings_mod.UNRAID_API_URL
|
||||
original_key = settings_mod.UNRAID_API_KEY
|
||||
try:
|
||||
settings_mod.UNRAID_API_URL = None
|
||||
settings_mod.UNRAID_API_KEY = None
|
||||
with pytest.raises(CredentialsNotConfiguredError):
|
||||
await make_graphql_request("{ __typename }")
|
||||
finally:
|
||||
settings_mod.UNRAID_API_URL = original_url
|
||||
settings_mod.UNRAID_API_KEY = original_key
|
||||
|
||||
Reference in New Issue
Block a user