@@ -622,130 +622,3 @@ def test_toolbox_tool_underscore_client_headers_property(toolbox_tool: ToolboxTo
622622 # Verify immutability
623623 with pytest .raises (TypeError ):
624624 client_headers ["new_header" ] = "new_value"
625-
626-
627- # --- Test for the HTTP Warning ---
628- @pytest .mark .parametrize (
629- "trigger_condition_params" ,
630- [
631- {"client_headers" : {"X-Some-Header" : "value" }},
632- {"required_authn_params" : {"param1" : ["auth-service1" ]}},
633- {"required_authz_tokens" : ["auth-service2" ]},
634- {
635- "client_headers" : {"X-Some-Header" : "value" },
636- "required_authn_params" : {"param1" : ["auth-service1" ]},
637- },
638- {
639- "client_headers" : {"X-Some-Header" : "value" },
640- "required_authz_tokens" : ["auth-service2" ],
641- },
642- {
643- "required_authn_params" : {"param1" : ["auth-service1" ]},
644- "required_authz_tokens" : ["auth-service2" ],
645- },
646- {
647- "client_headers" : {"X-Some-Header" : "value" },
648- "required_authn_params" : {"param1" : ["auth-service1" ]},
649- "required_authz_tokens" : ["auth-service2" ],
650- },
651- ],
652- ids = [
653- "client_headers_only" ,
654- "authn_params_only" ,
655- "authz_tokens_only" ,
656- "headers_and_authn" ,
657- "headers_and_authz" ,
658- "authn_and_authz" ,
659- "all_three_conditions" ,
660- ],
661- )
662- def test_tool_init_http_warning_when_sensitive_info_over_http (
663- http_session : ClientSession ,
664- sample_tool_params : list [ParameterSchema ],
665- sample_tool_description : str ,
666- trigger_condition_params : dict ,
667- ):
668- """
669- Tests that a UserWarning is issued if client headers, auth params, or
670- auth tokens are present and the base_url is HTTP.
671- """
672- expected_warning_message : str = (
673- "Sending ID token over HTTP. User data may be exposed. "
674- "Use HTTPS for secure communication."
675- )
676- transport = ToolboxTransport (TEST_BASE_URL , http_session )
677- init_kwargs = {
678- "transport" : transport ,
679- "name" : "http_warning_tool" ,
680- "description" : sample_tool_description ,
681- "params" : sample_tool_params ,
682- "required_authn_params" : {},
683- "required_authz_tokens" : [],
684- "auth_service_token_getters" : {},
685- "bound_params" : {},
686- "client_headers" : {},
687- }
688- # Apply the specific conditions for this parametrized test
689- init_kwargs .update (trigger_condition_params )
690-
691- with pytest .warns (UserWarning , match = expected_warning_message ):
692- ToolboxTool (** init_kwargs )
693-
694-
695- def test_tool_init_no_http_warning_if_https (
696- http_session : ClientSession ,
697- sample_tool_params : list [ParameterSchema ],
698- sample_tool_description : str ,
699- static_client_header : dict ,
700- ):
701- """
702- Tests that NO UserWarning is issued if client headers are present but
703- the base_url is HTTPS.
704- """
705- with catch_warnings (record = True ) as record :
706- simplefilter ("always" )
707- transport = ToolboxTransport (HTTPS_BASE_URL , http_session )
708-
709- ToolboxTool (
710- transport = transport ,
711- name = "https_tool" ,
712- description = sample_tool_description ,
713- params = sample_tool_params ,
714- required_authn_params = {},
715- required_authz_tokens = [],
716- auth_service_token_getters = {},
717- bound_params = {},
718- client_headers = static_client_header ,
719- )
720- assert (
721- len (record ) == 0
722- ), f"Expected no warnings, but got: { [f'{ w .category .__name__ } : { w .message } ' for w in record ]} "
723-
724-
725- def test_tool_init_no_http_warning_if_no_sensitive_info_on_http (
726- http_session : ClientSession ,
727- sample_tool_params : list [ParameterSchema ],
728- sample_tool_description : str ,
729- ):
730- """
731- Tests that NO UserWarning is issued if the URL is HTTP but there are
732- no client headers, auth params, or auth tokens.
733- """
734- with catch_warnings (record = True ) as record :
735- simplefilter ("always" )
736- transport = ToolboxTransport (TEST_BASE_URL , http_session )
737-
738- ToolboxTool (
739- transport = transport ,
740- name = "http_tool_no_sensitive" ,
741- description = sample_tool_description ,
742- params = sample_tool_params ,
743- required_authn_params = {},
744- required_authz_tokens = [],
745- auth_service_token_getters = {},
746- bound_params = {},
747- client_headers = {},
748- )
749- assert (
750- len (record ) == 0
751- ), f"Expected no warnings, but got: { [f'{ w .category .__name__ } : { w .message } ' for w in record ]} "
0 commit comments