@@ -96,13 +96,33 @@ def test_ssm_fips_endpoint(self, mock_boto3_client):
9696 }
9797 mock_boto3_client .return_value = mock_client
9898
99+ os .environ ["AWS_REGION" ] = "us-east-1"
100+ os .environ ["DD_API_KEY_SSM_NAME" ] = "test-ssm-param"
101+
102+ api_key = api .get_api_key ()
103+
104+ mock_boto3_client .assert_called_with (
105+ "ssm" , endpoint_url = "https://ssm-fips.us-east-1.amazonaws.com"
106+ )
107+ self .assertEqual (api_key , "test-api-key" )
108+
109+ @patch ("datadog_lambda.config.Config.fips_mode_enabled" , True )
110+ @patch ("datadog_lambda.config.Config.is_gov_region" , True )
111+ @patch ("botocore.session.Session.create_client" )
112+ def test_ssm_gov_endpoint (self , mock_boto3_client ):
113+ mock_client = MagicMock ()
114+ mock_client .get_parameter .return_value = {
115+ "Parameter" : {"Value" : "test-api-key" }
116+ }
117+ mock_boto3_client .return_value = mock_client
118+
99119 os .environ ["AWS_REGION" ] = "us-gov-west-1"
100120 os .environ ["DD_API_KEY_SSM_NAME" ] = "test-ssm-param"
101121
102122 api_key = api .get_api_key ()
103123
104124 mock_boto3_client .assert_called_with (
105- "ssm" , endpoint_url = "https://ssm-fips.us-gov-west-1.amazonaws.com"
125+ "ssm" , endpoint_url = None
106126 )
107127 self .assertEqual (api_key , "test-api-key" )
108128
0 commit comments