@@ -101,7 +101,10 @@ def test_sigv4_exporter_init_invalid_cw_otlp_endpoint(self):
101101
102102 @patch ("requests.Session.post" )
103103 @patch ("botocore.auth.SigV4Auth.add_auth" )
104- def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint (self , mock_sigv4_auth , requests_mock ):
104+ @patch ("botocore.session.Session" )
105+ def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint (
106+ self , botocore_mock , mock_sigv4_auth , requests_mock
107+ ):
105108 """Tests that if the OTLP endpoint is not a valid XRay endpoint but the credentials are valid,
106109 SigV4 authentication method is called but fails so NO headers are injected into the existing Session headers."""
107110
@@ -119,6 +122,13 @@ def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint(self,
119122 # SigV4 mock authentication injection
120123 mock_sigv4_auth .side_effect = self .mock_add_auth
121124
125+ mock_botocore_session = MagicMock ()
126+ botocore_mock .return_value = mock_botocore_session
127+
128+ mock_botocore_session .get_credentials .return_value = Credentials (
129+ access_key = "test_key" , secret_key = "test_secret" , token = "test_token"
130+ )
131+
122132 # For each invalid CW OTLP endpoint, validate that SigV4 is not injected
123133 self .invalid_otlp_tracing_endpoints .append ("https://xray.bad-region-1.amazonaws.com/v1/traces" )
124134 for bad_endpoint in self .invalid_otlp_tracing_endpoints :
0 commit comments