8787 get_cloud_client,
8888 nuke_prefixed_buckets,
8989 configured_storage_classes,
90+ configure,
9091 get_lc_debug_interval,
9192 get_restore_debug_interval,
9293 get_read_through_days,
@@ -16523,8 +16524,8 @@ def test_get_object_attributes():
1652316524 },
1652416525 'sse-c': {
1652516526 'args': {
16526- 'SSECustomerAlgorithm': 'AES256',
16527- 'SSECustomerKey': 'pO3upElrwuEXSoFwCfnZPdSsmt/xWeFa0N9KgDijwVs=',
16527+ 'SSECustomerAlgorithm': 'AES256',
16528+ 'SSECustomerKey': 'pO3upElrwuEXSoFwCfnZPdSsmt/xWeFa0N9KgDijwVs=',
1652816529 'SSECustomerKeyMD5': 'DWygnHRtgiJ77HCm+1rvHw==',
1652916530 },
1653016531 'source_copy_args': {
@@ -16535,7 +16536,7 @@ def test_get_object_attributes():
1653516536 },
1653616537 'sse-kms': {
1653716538 'args': {
16538- 'ServerSideEncryption': 'aws:kms',
16539+ 'ServerSideEncryption': 'aws:kms',
1653916540 'SSEKMSKeyId': lambda: get_main_kms_keyid()
1654016541 },
1654116542 }
@@ -16567,7 +16568,7 @@ def test_get_object_attributes():
1656716568 },
1656816569 'sse-kms': {
1656916570 'args': {
16570- 'ServerSideEncryption': 'aws:kms',
16571+ 'ServerSideEncryption': 'aws:kms',
1657116572 'SSEKMSKeyId': lambda: get_secondary_kms_keyid()
1657216573 },
1657316574 'assert': lambda r: (
@@ -16577,7 +16578,7 @@ def test_get_object_attributes():
1657716578 }
1657816579}
1657916580
16580- def _test_copy_enc(file_size, source_mode_key, dest_mode_key):
16581+ def _test_copy_enc(file_size, source_mode_key, dest_mode_key, source_sc=None, dest_sc=None ):
1658116582 source_args = _copy_enc_source_modes[source_mode_key]
1658216583 dest_args = _copy_enc_dest_modes[dest_mode_key]
1658316584
@@ -16587,13 +16588,17 @@ def _test_copy_enc(file_size, source_mode_key, dest_mode_key):
1658716588 # upload original file with source encryption
1658816589 data = 'A'*file_size
1658916590 args = {key: value() if callable(value) else value for key, value in source_args.get('args', {}).items()}
16591+ if source_sc:
16592+ args['StorageClass'] = source_sc
1659016593 response = client.put_object(Bucket=bucket_name, Key='testobj', Body=data, **args)
1659116594 assert source_args.get('assert', lambda r: True)(response)
1659216595
1659316596 # copy the object to a new key, with destination encryption
1659416597 dest_bucket_name = get_new_bucket()
1659516598 copy_args = {key: value() if callable(value) else value for key, value in dest_args.get('args', {}).items()}
1659616599 copy_args.update(source_args.get('source_copy_args', {}))
16600+ if dest_sc:
16601+ copy_args['StorageClass'] = dest_sc
1659716602 response = client.copy_object(Bucket=dest_bucket_name, Key='testobj2', CopySource={'Bucket': bucket_name, 'Key': 'testobj'}, **copy_args)
1659816603 assert dest_args.get('assert', lambda r: True)(response)
1659916604
@@ -16671,3 +16676,51 @@ def test_copy_enc_1mb(source_mode_key, dest_mode_key):
1667116676])
1667216677def test_copy_enc_8mb(source_mode_key, dest_mode_key):
1667316678 _test_copy_enc(8*1024*1024, source_mode_key, dest_mode_key)
16679+
16680+ def generate_copy_enc_storage_class_params():
16681+ configure()
16682+ sc = configured_storage_classes()
16683+ if len(sc) < 2:
16684+ return []
16685+
16686+ obj_sizes = [1, 1024, 1024*1024, 8*1024*1024]
16687+
16688+ params = []
16689+ for source_key in _copy_enc_source_modes.keys():
16690+ for dest_key in _copy_enc_dest_modes.keys():
16691+ source_marks = _copy_enc_source_modes[source_key].get('marks', [])
16692+ dest_marks = _copy_enc_dest_modes[dest_key].get('marks', [])
16693+
16694+ for source_sc in sc:
16695+ for dest_sc in sc:
16696+ if source_sc == dest_sc:
16697+ continue
16698+ for obj_size in obj_sizes:
16699+ param = pytest.param(
16700+ source_key,
16701+ dest_key,
16702+ source_sc,
16703+ dest_sc,
16704+ obj_size,
16705+ marks=[*source_marks, *dest_marks]
16706+ )
16707+ params.append(param)
16708+ return params
16709+
16710+ @pytest.mark.encryption
16711+ @pytest.mark.fails_on_dbstore
16712+ @pytest.mark.storage_class
16713+ @pytest.mark.fails_on_aws # storage classes are not there
16714+ @pytest.mark.parametrize(
16715+ "source_mode_key, dest_mode_key, source_storage_class, dest_storage_class, obj_size",
16716+ generate_copy_enc_storage_class_params()
16717+ )
16718+ def test_copy_enc_storage_class(source_mode_key, dest_mode_key, source_storage_class, dest_storage_class, obj_size):
16719+ if len(configured_storage_classes()) < 2:
16720+ pytest.skip('need at least two storage classes to test copy storage class')
16721+
16722+ print(
16723+ f"Testing copy from {source_mode_key} to {dest_mode_key} with storage class "
16724+ f"{source_storage_class} -> {dest_storage_class} and object size {obj_size}"
16725+ )
16726+ _test_copy_enc(obj_size, source_mode_key, dest_mode_key, source_storage_class, dest_storage_class)
0 commit comments