mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 19:27:23 +08:00
fix: test cases error
This commit is contained in:
parent
560b026523
commit
eba703083e
@ -106,8 +106,8 @@ def handle_callback(state_key: str, authorization_code: str, mcp_service: "MCPTo
|
|||||||
|
|
||||||
def check_support_resource_discovery(server_url: str) -> tuple[bool, str]:
|
def check_support_resource_discovery(server_url: str) -> tuple[bool, str]:
|
||||||
"""Check if the server supports OAuth 2.0 Resource Discovery."""
|
"""Check if the server supports OAuth 2.0 Resource Discovery."""
|
||||||
b_scheme, b_netloc, _, _, b_query, b_fragment = urlparse(server_url, "", True)
|
b_scheme, b_netloc, b_path, _, b_query, b_fragment = urlparse(server_url, "", True)
|
||||||
url_for_resource_discovery = f"{b_scheme}://{b_netloc}/.well-known/oauth-protected-resource"
|
url_for_resource_discovery = f"{b_scheme}://{b_netloc}/.well-known/oauth-protected-resource{b_path}"
|
||||||
if b_query:
|
if b_query:
|
||||||
url_for_resource_discovery += f"?{b_query}"
|
url_for_resource_discovery += f"?{b_query}"
|
||||||
if b_fragment:
|
if b_fragment:
|
||||||
|
|||||||
@ -189,7 +189,7 @@ class TestOAuthDiscovery:
|
|||||||
def test_discover_oauth_metadata_with_resource_discovery(self, mock_get):
|
def test_discover_oauth_metadata_with_resource_discovery(self, mock_get):
|
||||||
"""Test OAuth metadata discovery with resource discovery support."""
|
"""Test OAuth metadata discovery with resource discovery support."""
|
||||||
with patch("core.mcp.auth.auth_flow.check_support_resource_discovery") as mock_check:
|
with patch("core.mcp.auth.auth_flow.check_support_resource_discovery") as mock_check:
|
||||||
mock_check.return_value = (True, "https://auth.example.com/.well-known/oauth-authorization-server")
|
mock_check.return_value = (True, "https://auth.example.com")
|
||||||
|
|
||||||
mock_response = Mock()
|
mock_response = Mock()
|
||||||
mock_response.status_code = 200
|
mock_response.status_code = 200
|
||||||
@ -207,7 +207,7 @@ class TestOAuthDiscovery:
|
|||||||
assert metadata.authorization_endpoint == "https://auth.example.com/authorize"
|
assert metadata.authorization_endpoint == "https://auth.example.com/authorize"
|
||||||
assert metadata.token_endpoint == "https://auth.example.com/token"
|
assert metadata.token_endpoint == "https://auth.example.com/token"
|
||||||
mock_get.assert_called_once_with(
|
mock_get.assert_called_once_with(
|
||||||
"https://auth.example.com/.well-known/oauth-authorization-server",
|
"https://auth.example.com/.well-known/openid-configuration",
|
||||||
headers={"MCP-Protocol-Version": "2025-03-26"},
|
headers={"MCP-Protocol-Version": "2025-03-26"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user