@@ -429,53 +429,6 @@ def test_from_config_no_state_mapping_no_provider(self):
429429 # No header provider should be created
430430 assert toolset ._header_provider is None
431431
432- def test_from_config_with_credential_key (self ):
433- """Test that from_config creates header provider from credential_key."""
434- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
435- from google .adk .tools .tool_configs import ToolArgsConfig
436-
437- config = ToolArgsConfig (
438- stdio_server_params = {"command" : "test_command" , "args" : []},
439- credential_key = "my_token" ,
440- )
441-
442- toolset = McpToolset .from_config (config , "/fake/path" )
443-
444- assert toolset ._header_provider is not None
445-
446- mock_context = Mock (spec = ReadonlyContext )
447- mock_context .state = {"my_token" : "test-jwt-123" }
448-
449- headers = toolset ._header_provider (mock_context )
450-
451- assert headers == {"Authorization" : "Bearer test-jwt-123" }
452-
453- def test_from_config_credential_key_with_state_header_mapping (self ):
454- """Test that credential_key and state_header_mapping combine."""
455- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
456- from google .adk .tools .tool_configs import ToolArgsConfig
457-
458- config = ToolArgsConfig (
459- stdio_server_params = {"command" : "test_command" , "args" : []},
460- credential_key = "jwt_token" ,
461- state_header_mapping = {"tenant_id" : "X-Tenant-ID" },
462- )
463-
464- toolset = McpToolset .from_config (config , "/fake/path" )
465-
466- mock_context = Mock (spec = ReadonlyContext )
467- mock_context .state = {
468- "jwt_token" : "my-jwt" ,
469- "tenant_id" : "tenant-42" ,
470- }
471-
472- headers = toolset ._header_provider (mock_context )
473-
474- assert headers == {
475- "Authorization" : "Bearer my-jwt" ,
476- "X-Tenant-ID" : "tenant-42" ,
477- }
478-
479432 def test_from_config_with_strict_mode (self ):
480433 """Test that from_config respects state_header_strict setting."""
481434 from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
@@ -500,77 +453,6 @@ def test_from_config_with_strict_mode(self):
500453 assert "dict" in str (exc_info .value )
501454
502455
503- class TestCredentialKey :
504- """Test suite for credential_key on McpToolset.__init__."""
505-
506- def test_credential_key_creates_bearer_header (self ):
507- """Test credential_key reads token from state and sends as Bearer."""
508- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
509-
510- toolset = McpToolset (
511- connection_params = StdioServerParameters (command = "echo" , args = []),
512- credential_key = "auth_token" ,
513- )
514-
515- assert toolset ._header_provider is not None
516-
517- mock_context = Mock (spec = ReadonlyContext )
518- mock_context .state = {"auth_token" : "my-jwt-token" }
519-
520- headers = toolset ._header_provider (mock_context )
521-
522- assert headers == {"Authorization" : "Bearer my-jwt-token" }
523-
524- def test_credential_key_missing_state_returns_empty (self ):
525- """Test credential_key returns empty headers when key not in state."""
526- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
527-
528- toolset = McpToolset (
529- connection_params = StdioServerParameters (command = "echo" , args = []),
530- credential_key = "auth_token" ,
531- )
532-
533- mock_context = Mock (spec = ReadonlyContext )
534- mock_context .state = {}
535-
536- headers = toolset ._header_provider (mock_context )
537-
538- assert headers == {}
539-
540- def test_credential_key_none_means_no_provider (self ):
541- """Test that credential_key=None does not create a provider."""
542- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
543-
544- toolset = McpToolset (
545- connection_params = StdioServerParameters (command = "echo" , args = []),
546- credential_key = None ,
547- )
548-
549- assert toolset ._header_provider is None
550-
551- def test_credential_key_combines_with_header_provider (self ):
552- """Test that credential_key and header_provider are combined."""
553- from google .adk .tools .mcp_tool .mcp_toolset import McpToolset
554-
555- custom_provider = lambda ctx : {"X-Custom" : "value" }
556-
557- toolset = McpToolset (
558- connection_params = StdioServerParameters (command = "echo" , args = []),
559- credential_key = "auth_token" ,
560- header_provider = custom_provider ,
561- )
562-
563- mock_context = Mock (spec = ReadonlyContext )
564- mock_context .state = {"auth_token" : "my-jwt" }
565-
566- headers = toolset ._header_provider (mock_context )
567-
568- assert headers == {
569- "Authorization" : "Bearer my-jwt" ,
570- "X-Custom" : "value" ,
571- }
572-
573-
574456class TestRFC7230Compliance :
575457 """Test suite for RFC 7230 compliant header handling."""
576458
0 commit comments