aminghadersohi commented on code in PR #39604:
URL: https://github.com/apache/superset/pull/39604#discussion_r3342387534


##########
tests/unit_tests/mcp_service/test_mcp_server.py:
##########
@@ -158,3 +158,26 @@ def 
test_create_event_store_returns_none_when_redis_store_fails():
         result = create_event_store(config)
 
         assert result is None
+
+
+def test_create_auth_provider_uses_default_factory_for_mcp_api_key_only() -> 
None:
+    """MCP_API_KEY_ENABLED=True should install auth even when FAB API keys are 
off."""
+    from superset.mcp_service.server import _create_auth_provider
+
+    flask_app = MagicMock()
+    flask_app.config.get.side_effect = lambda key, default=None: {
+        "MCP_AUTH_FACTORY": None,
+        "MCP_AUTH_ENABLED": False,
+        "MCP_API_KEY_ENABLED": True,
+        "FAB_API_KEY_ENABLED": False,
+    }.get(key, default)
+    auth_provider = MagicMock()
+
+    with patch(
+        "superset.mcp_service.mcp_config.create_default_mcp_auth_factory",
+        return_value=auth_provider,
+    ) as create_default_mcp_auth_factory:
+        result = _create_auth_provider(flask_app)
+
+    assert result is auth_provider
+    create_default_mcp_auth_factory.assert_called_once_with(flask_app)

Review Comment:
   Done — added three tests in `test_mcp_config.py` (commit a28b3c0f) that 
directly invoke `_build_composite_verifier`:
   1. String `FAB_API_KEY_PREFIXES` (`"sst_"`) → wrapped into `("sst_",)`
   2. List `FAB_API_KEY_PREFIXES` (`["sst_", "api_"]`) → passed through as-is
   3. `None` (non-iterable) → falls back to default `("sst_",)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to