Files
unraid-mcp/tests/test_oidc.py
Jacob Magar efaab031ae fix: address all 17 PR review comments
Resolves review threads:
- PRRT_kwDOO6Hdxs50fewG (setup.py): non-eliciting clients now return True
  from elicit_reset_confirmation so they can reconfigure without being blocked
- PRRT_kwDOO6Hdxs50fewM (test-tools.sh): add notification/recalculate smoke test
- PRRT_kwDOO6Hdxs50fewP (test-tools.sh): add system/array smoke test
- PRRT_kwDOO6Hdxs50fewT (resources.py): surface manager error state instead of
  reporting 'connecting' for permanently failed subscriptions
- PRRT_kwDOO6Hdxs50feAj (resources.py): use is not None check for empty cached dicts
- PRRT_kwDOO6Hdxs50fewY (integration tests): remove duplicate snapshot-registration
  tests already covered in test_resources.py
- PRRT_kwDOO6Hdxs50fewe (test_resources.py): replace brittle import-detail test
  with behavior tests for connecting/error states
- PRRT_kwDOO6Hdxs50fewh (test_customization.py): strengthen public_theme assertion
- PRRT_kwDOO6Hdxs50fewk (test_customization.py): strengthen theme assertion
- PRRT_kwDOO6Hdxs50fewo (__init__.py): correct subaction count ~88 -> ~107
- PRRT_kwDOO6Hdxs50fewx (test_oidc.py): assert providers list value directly
- PRRT_kwDOO6Hdxs50fewz (unraid.py): remove unreachable raise after vm handler
- PRRT_kwDOO6Hdxs50few2 (unraid.py): remove unreachable raise after docker handler
- PRRT_kwDOO6Hdxs50fev8 (CLAUDE.md): replace legacy 15-tool table with unified
  unraid action/subaction table
- PRRT_kwDOO6Hdxs50fev_ (test_oidc.py): assert providers + defaultAllowedOrigins
- PRRT_kwDOO6Hdxs50feAz (CLAUDE.md): update tool categories to unified API shape
- PRRT_kwDOO6Hdxs50feBE (CLAUDE.md/setup.py): update unraid_health refs to
  unraid(action=health, subaction=setup)
2026-03-16 02:58:54 -04:00

65 lines
1.9 KiB
Python

# tests/test_oidc.py
"""Tests for oidc subactions of the consolidated unraid tool."""
from __future__ import annotations
from unittest.mock import AsyncMock, patch
import pytest
from conftest import make_tool_fn
@pytest.fixture
def _mock_graphql():
with patch("unraid_mcp.tools.unraid.make_graphql_request", new_callable=AsyncMock) as m:
yield m
def _make_tool():
return make_tool_fn("unraid_mcp.tools.unraid", "register_unraid_tool", "unraid")
@pytest.mark.asyncio
async def test_providers_returns_list(_mock_graphql):
_mock_graphql.return_value = {
"oidcProviders": [
{"id": "1:local", "name": "Google", "clientId": "abc", "scopes": ["openid"]}
]
}
result = await _make_tool()(action="oidc", subaction="providers")
assert "providers" in result
assert len(result["providers"]) == 1
@pytest.mark.asyncio
async def test_public_providers(_mock_graphql):
_mock_graphql.return_value = {"publicOidcProviders": []}
result = await _make_tool()(action="oidc", subaction="public_providers")
assert result["providers"] == []
@pytest.mark.asyncio
async def test_provider_requires_provider_id(_mock_graphql):
from unraid_mcp.core.exceptions import ToolError
with pytest.raises(ToolError, match="provider_id"):
await _make_tool()(action="oidc", subaction="provider")
@pytest.mark.asyncio
async def test_validate_session_requires_token(_mock_graphql):
from unraid_mcp.core.exceptions import ToolError
with pytest.raises(ToolError, match="token"):
await _make_tool()(action="oidc", subaction="validate_session")
@pytest.mark.asyncio
async def test_configuration(_mock_graphql):
_mock_graphql.return_value = {
"oidcConfiguration": {"providers": [], "defaultAllowedOrigins": []}
}
result = await _make_tool()(action="oidc", subaction="configuration")
assert result["providers"] == []
assert result["defaultAllowedOrigins"] == []