Repository: boto/botocore
Pull request #831 (2016-03-04 17:49:04)

Pass service_signing_name to ClientEndpointBridge
This was being passed as the 4th positional argument
to ClientEndpointBridge which is the ``default_endpoint``,
not the ``service_signing_name``.  Passing this value
as a kwarg to be explicit.

I also fixed a case where the signingName from the service
was not being used in the case where we assume an endpoint
if we can't resolve anything from the endpoint resolver.

Fixes boto/boto3#538

cc @kyleknap @JordonPhillips 


Patch:
diff --git a/botocore/client.py b/botocore/client.py
index c31f9c725..4ed274c6f 100644
--- a/botocore/client.py
+++ b/botocore/client.py
@@ -145,7 +145,7 @@ class ClientCreator(object):
         response_parser = botocore.parsers.create_parser(protocol)
         endpoint_bridge = ClientEndpointBridge(
             self._endpoint_resolver, scoped_config, client_config,
-            service_model.metadata.get('signingName'))
+            service_signing_name=service_model.metadata.get('signingName'))
         endpoint_config = endpoint_bridge.resolve(
             service_name, region_name, endpoint_url, is_secure)
 
@@ -313,9 +313,10 @@ class ClientEndpointBridge(object):
         # We still want to allow the user to provide an explicit version.
         signature_version = self._resolve_signature_version(
             service_name, {'signatureVersions': ['v4']})
+        signing_name = self._resolve_signing_name(service_name, resolved={})
         return self._create_result(
             service_name=service_name, region_name=region_name,
-            signing_region=region_name, signing_name=service_name,
+            signing_region=region_name, signing_name=signing_name,
             signature_version=signature_version, endpoint_url=endpoint_url,
             metadata={})
 


Test patch:
diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py
index d17f1f5a0..6ee15b15a 100644
--- a/tests/unit/test_client.py
+++ b/tests/unit/test_client.py
@@ -333,6 +333,35 @@ class TestAutoGeneratedClient(unittest.TestCase):
             call_args = mock_signer.call_args
             self.assertEquals('us-west-2', call_args[0][1])
 
+    def test_client_uses_signing_name_from_model_if_present_if_resolved(self):
+        self.service_description['metadata']['signingName'] = 'otherName'
+        with mock.patch('botocore.client.RequestSigner') as mock_signer:
+            self.resolver.construct_endpoint.return_value = {
+                'partition': 'aws',
+                'endpointName': 'us-west-2',
+                'hostname': 'endpoint.url',
+                'signatureVersions': ['v4'],
+            }
+            creator = self.create_client_creator()
+            service_client = creator.create_client(
+                service_name='myservice', region_name='us-west-2',
+                credentials=self.credentials, endpoint_url='https://foo')
+            self.assertEqual(service_client.meta.region_name, 'us-west-2')
+            call_args = mock_signer.call_args[0]
+            self.assertEquals('otherName', call_args[2])
+
+    def test_client_uses_signing_name_even_with_no_resolve(self):
+        self.service_description['metadata']['signingName'] = 'otherName'
+        with mock.patch('botocore.client.RequestSigner') as mock_signer:
+            self.resolver.construct_endpoint.return_value = {}
+            creator = self.create_client_creator()
+            service_client = creator.create_client(
+                service_name='myservice', region_name='us-west-2',
+                credentials=self.credentials, endpoint_url='https://foo')
+            self.assertEqual(service_client.meta.region_name, 'us-west-2')
+            call_args = mock_signer.call_args[0]
+            self.assertEquals('otherName', call_args[2])
+
     @mock.patch('botocore.client.RequestSigner')
     def test_client_signature_no_override(self, request_signer):
         creator = self.create_client_creator()