Repository: boto/botocore
Pull request #3068 (2023-11-21 20:42:54)

Add private shim to fetch credentials
This is for internal use for retrieving resolved credentials off a client when a Session credential resolver isn't readily available. It is subject to unannounced breakages and shouldn't be accessed publicly.

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/boto/botocore/pull/3068?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boto) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`3f645d1`)](https://app.codecov.io/gh/boto/botocore/commit/3f645d1b28152d3ae901298e6e88bad220f4b3fd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boto) 93.46% compared to head [(`3fb38a4`)](https://app.codecov.io/gh/boto/botocore/pull/3068?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boto) 93.38%.
> Report is 52 commits behind head on develop.


:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff             @@
##           develop    #3068      +/-   ##
===========================================
- Coverage    93.46%   93.38%   -0.08%     
===========================================
  Files           66       66              
  Lines        14007    14038      +31     
===========================================
+ Hits         13091    13110      +19     
- Misses         916      928      +12     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/boto/botocore/pull/3068?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boto).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=boto).


Patch:
diff --git a/botocore/client.py b/botocore/client.py
index 8bd63f07a..9a8987799 100644
--- a/botocore/client.py
+++ b/botocore/client.py
@@ -1253,6 +1253,13 @@ class BaseClient:
             self._service_model
         )
 
+    def _get_credentials(self):
+        """
+        This private interface is subject to abrupt breaking changes, including
+        removal, in any botocore release.
+        """
+        return self._request_signer._credentials
+
 
 class ClientMeta:
     """Holds additional client methods.


Test patch:
diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py
index 8dbad2646..962dab01a 100644
--- a/tests/unit/test_client.py
+++ b/tests/unit/test_client.py
@@ -1689,6 +1689,17 @@ class TestAutoGeneratedClient(unittest.TestCase):
 
         self.endpoint.close.assert_called_once_with()
 
+    def test_client_internal_credential_shim(self):
+        """This test exercises the internal credential shim exposed on clients.
+        It's here to ensure we don't unintentionally regress behavior used with
+        our upload/download operations in s3transfer with the CRT.
+        """
+        creator = self.create_client_creator()
+        service_client = creator.create_client(
+            'myservice', 'us-west-2', credentials=self.credentials
+        )
+        self.assertEqual(service_client._get_credentials(), self.credentials)
+
 
 class TestClientErrors(TestAutoGeneratedClient):
     def add_error_response(self, error_response):