Copilot commented on code in PR #2181:
URL: https://github.com/apache/libcloud/pull/2181#discussion_r3903959385
##########
libcloud/test/storage/test_azure_blobs.py:
##########
@@ -520,6 +521,19 @@ def test_get_object_cdn_url_put(self):
self.assertEqual(len(query["sig"]), 1)
self.assertGreater(len(query["sig"][0]), 0)
+ @patch("libcloud.storage.drivers.azure_blobs.hmac.new")
+ def test_get_object_cdn_url_with_spaces(self, mock_hmac_new):
+ mock_hmac_new.return_value.digest.return_value = b"signature"
+ container = Container(name="test_container200", extra={},
driver=self.driver)
+ obj = Object("file name.txt", 0, None, {}, {}, container, self.driver)
+
+ url = self.driver.get_object_cdn_url(obj)
+ string_to_sign = mock_hmac_new.call_args.args[1].decode("utf-8")
Review Comment:
`mock_hmac_new.call_args.args[1]` is brittle because it assumes the
implementation always passes the HMAC message as the 2nd positional argument.
If the production code switches to using keyword arguments (e.g., `msg=`) or
changes positional ordering, this test will break even though behavior is
unchanged. Consider extracting the message from either
`call_args.kwargs.get('msg')` (or equivalent) fallback to positional args, or
asserting against a helper that returns the string-to-sign rather than
inspecting HMAC call internals.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]