From c202da6fe57298fed87c5a57871b953303883cf3 Mon Sep 17 00:00:00 2001 From: Nate Prewitt Date: Fri, 15 Nov 2024 14:11:29 -0700 Subject: [PATCH] Add tests --- tests/functional/s3transfer/test_crt.py | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/functional/s3transfer/test_crt.py b/tests/functional/s3transfer/test_crt.py index 8ec3f23f0e99..cb6c67e1a221 100644 --- a/tests/functional/s3transfer/test_crt.py +++ b/tests/functional/s3transfer/test_crt.py @@ -69,6 +69,8 @@ def setUp(self): self.region = 'us-west-2' self.bucket = "test_bucket" self.s3express_bucket = 's3expressbucket--usw2-az5--x-s3' + self.mrap_accesspoint = 'arn:aws:s3::123456789012:accesspoint/mfzwi23gnjvgw.mrap' + self.mrap_bucket = 'mfzwi23gnjvgw.mrap' self.key = "test_key" self.expected_content = b'my content' self.expected_download_content = b'new content' @@ -82,6 +84,8 @@ def setUp(self): f'{self.s3express_bucket}.s3express-usw2-az5.us-west-2.amazonaws.com' ) self.expected_s3express_path = f'/{self.key}' + self.expected_mrap_host = f'{self.mrap_bucket}.accesspoint.s3-global.amazonaws.com' + self.expected_mrap_path = f"/{self.key}" self.s3_request = mock.Mock(awscrt.s3.S3Request) self.s3_crt_client = mock.Mock(awscrt.s3.S3Client) self.s3_crt_client.make_request.side_effect = ( @@ -156,6 +160,26 @@ def _assert_exected_s3express_request( awscrt.auth.AwsSigningAlgorithm.V4_S3EXPRESS ) + def _assert_exected_mrap_request( + self, + make_request_kwargs, + expected_http_method='GET' + ): + self._assert_expected_crt_http_request( + make_request_kwargs["request"], + expected_host=self.expected_mrap_host, + expected_path=self.expected_mrap_path, + expected_http_method=expected_http_method, + ) + self.assertIn('signing_config', make_request_kwargs) + self.assertEqual( + make_request_kwargs['signing_config'].algorithm, + awscrt.auth.AwsSigningAlgorithm.V4_ASYMMETRIC + ) + self.assertEqual( + make_request_kwargs['signing_config'].region, "*" + ) + def _assert_subscribers_called(self, expected_future=None): self.assertTrue(self.record_subscriber.on_queued_called) self.assertTrue(self.record_subscriber.on_done_called) @@ -388,6 +412,17 @@ def test_upload_with_s3express(self): expected_http_method='PUT' ) + def test_upload_with_mrap(self): + future = self.transfer_manager.upload( + self.filename, self.mrap_accesspoint, self.key, {}, + [self.record_subscriber] + ) + future.result() + self._assert_exected_mrap_request( + self.s3_crt_client.make_request.call_args[1], + expected_http_method='PUT' + ) + def test_download(self): future = self.transfer_manager.download( self.bucket, self.key, self.filename, {}, [self.record_subscriber] @@ -501,6 +536,17 @@ def test_download_with_s3express(self): expected_http_method='GET' ) + def test_download_with_mrap(self): + future = self.transfer_manager.download( + self.mrap_accesspoint, self.key, self.filename, {}, + [self.record_subscriber] + ) + future.result() + self._assert_exected_mrap_request( + self.s3_crt_client.make_request.call_args[1], + expected_http_method='GET' + ) + def test_delete(self): future = self.transfer_manager.delete( self.bucket, self.key, {}, [self.record_subscriber]