@@ -239,9 +239,9 @@ def test_static_files(self, test_client):
239
239
class TestProtocolEndpoints :
240
240
"""Tests for MCP protocol operations: initialize, ping, notifications, etc."""
241
241
242
- @patch ("mcpgateway.main.validate_request" )
242
+ # @patch("mcpgateway.main.validate_request")
243
243
@patch ("mcpgateway.main.session_registry.handle_initialize_logic" )
244
- def test_initialize_endpoint (self , mock_handle_initialize , _mock_validate , test_client , auth_headers ):
244
+ def test_initialize_endpoint (self , mock_handle_initialize , test_client , auth_headers ):
245
245
"""Test MCP protocol initialization."""
246
246
mock_capabilities = ServerCapabilities (
247
247
prompts = {"listChanged" : True },
@@ -271,8 +271,8 @@ def test_initialize_endpoint(self, mock_handle_initialize, _mock_validate, test_
271
271
assert body ["protocolVersion" ] == PROTOCOL_VERSION
272
272
mock_handle_initialize .assert_called_once ()
273
273
274
- @patch ("mcpgateway.main.validate_request" )
275
- def test_ping_endpoint (self , _mock_validate , test_client , auth_headers ):
274
+ # @patch("mcpgateway.main.validate_request")
275
+ def test_ping_endpoint (self , test_client , auth_headers ):
276
276
"""Test MCP ping endpoint."""
277
277
req = {"jsonrpc" : "2.0" , "method" : "ping" , "id" : "test-id" }
278
278
response = test_client .post ("/protocol/ping" , json = req , headers = auth_headers )
@@ -807,8 +807,8 @@ def test_rpc_tool_invocation(self, mock_invoke_tool, test_client, auth_headers):
807
807
mock_invoke_tool .assert_called_once_with (db = ANY , name = "test_tool" , arguments = {"param" : "value" })
808
808
809
809
@patch ("mcpgateway.main.prompt_service.get_prompt" )
810
- @patch ("mcpgateway.main.validate_request" )
811
- def test_rpc_prompt_get (self , _mock_validate , mock_get_prompt , test_client , auth_headers ):
810
+ # @patch("mcpgateway.main.validate_request")
811
+ def test_rpc_prompt_get (self , mock_get_prompt , test_client , auth_headers ):
812
812
"""Test prompt retrieval via JSON-RPC."""
813
813
mock_get_prompt .return_value = {
814
814
"messages" : [{"role" : "user" , "content" : {"type" : "text" , "text" : "Rendered prompt" }}],
@@ -829,8 +829,8 @@ def test_rpc_prompt_get(self, _mock_validate, mock_get_prompt, test_client, auth
829
829
mock_get_prompt .assert_called_once_with (ANY , "test_prompt" , {"param" : "value" })
830
830
831
831
@patch ("mcpgateway.main.tool_service.list_tools" )
832
- @patch ("mcpgateway.main.validate_request" )
833
- def test_rpc_list_tools (self , _mock_validate , mock_list_tools , test_client , auth_headers ):
832
+ # @patch("mcpgateway.main.validate_request")
833
+ def test_rpc_list_tools (self , mock_list_tools , test_client , auth_headers ):
834
834
"""Test listing tools via JSON-RPC."""
835
835
mock_tool = MagicMock ()
836
836
mock_tool .model_dump .return_value = MOCK_TOOL_READ
@@ -849,26 +849,26 @@ def test_rpc_list_tools(self, _mock_validate, mock_list_tools, test_client, auth
849
849
assert isinstance (body , list )
850
850
mock_list_tools .assert_called_once ()
851
851
852
- @patch ("mcpgateway.main.validate_request " )
853
- def test_rpc_invalid_request (self , mock_validate , test_client , auth_headers ):
852
+ @patch ("mcpgateway.main.RPCRequest " )
853
+ def test_rpc_invalid_request (self , mock_rpc_request , test_client , auth_headers ):
854
854
"""Test RPC error handling for invalid requests."""
855
- mock_validate .side_effect = Exception ("Invalid request " )
855
+ mock_rpc_request .side_effect = ValueError ("Invalid method " )
856
856
857
857
req = {"jsonrpc" : "1.0" , "id" : "test-id" , "method" : "invalid_method" }
858
858
response = test_client .post ("/rpc/" , json = req , headers = auth_headers )
859
859
860
- assert response .status_code == 200
860
+ assert response .status_code == 422
861
861
body = response .json ()
862
- assert "error" in body and "Invalid request" in body [ "error" ][ "data" ]
862
+ assert "Method invalid" in body . get ( "message" )
863
863
864
864
def test_rpc_invalid_json (self , test_client , auth_headers ):
865
865
"""Test RPC error handling for malformed JSON."""
866
866
headers = auth_headers
867
867
headers ["content-type" ] = "application/json"
868
868
response = test_client .post ("/rpc/" , content = "invalid json" , headers = headers )
869
- assert response .status_code == 200 # Returns error response, not HTTP error
869
+ assert response .status_code == 422 # Returns error response, not HTTP error
870
870
body = response .json ()
871
- assert "error " in body
871
+ assert "Method invalid " in body . get ( "message" )
872
872
873
873
@patch ("mcpgateway.main.logging_service.set_level" )
874
874
def test_set_log_level_endpoint (self , mock_set_level , test_client , auth_headers ):
0 commit comments