@@ -1512,6 +1512,95 @@ def test_s3_copy_tagging_directive(self, s3_bucket, snapshot, aws_client, taggin
1512
1512
)
1513
1513
snapshot .match ("get-copy-object-tag-empty" , get_object_tags )
1514
1514
1515
+ @markers .aws .validated
1516
+ @markers .snapshot .skip_snapshot_verify (
1517
+ condition = is_v2_provider ,
1518
+ paths = ["$..ServerSideEncryption" ],
1519
+ )
1520
+ @pytest .mark .parametrize ("tagging_directive" , ["COPY" , "REPLACE" , None ])
1521
+ def test_s3_copy_tagging_directive_versioned (
1522
+ self , s3_bucket , snapshot , aws_client , tagging_directive
1523
+ ):
1524
+ snapshot .add_transformer (snapshot .transform .s3_api ())
1525
+ aws_client .s3 .put_bucket_versioning (
1526
+ Bucket = s3_bucket , VersioningConfiguration = {"Status" : "Enabled" }
1527
+ )
1528
+ object_key = "source-object"
1529
+ resp = aws_client .s3 .put_object (
1530
+ Bucket = s3_bucket , Key = object_key , Body = "test" , Tagging = "key1=value1"
1531
+ )
1532
+ snapshot .match ("put-object" , resp )
1533
+ version_1 = resp ["VersionId" ]
1534
+
1535
+ resp = aws_client .s3 .put_object (
1536
+ Bucket = s3_bucket , Key = object_key , Body = "test-v2" , Tagging = "key1=value1-v2"
1537
+ )
1538
+ snapshot .match ("put-object-v2" , resp )
1539
+
1540
+ get_object_tags = aws_client .s3 .get_object_tagging (Bucket = s3_bucket , Key = object_key )
1541
+ snapshot .match ("get-object-tag" , get_object_tags )
1542
+
1543
+ get_object_tags_v1 = aws_client .s3 .get_object_tagging (
1544
+ Bucket = s3_bucket , Key = object_key , VersionId = version_1
1545
+ )
1546
+ snapshot .match ("get-object-tag-v1" , get_object_tags_v1 )
1547
+
1548
+ kwargs = {"TaggingDirective" : tagging_directive } if tagging_directive else {}
1549
+
1550
+ object_key_copy = f"{ object_key } -copy"
1551
+ resp = aws_client .s3 .copy_object (
1552
+ Bucket = s3_bucket ,
1553
+ CopySource = f"{ s3_bucket } /{ object_key } " ,
1554
+ Key = object_key_copy ,
1555
+ Tagging = "key2=value2" ,
1556
+ ** kwargs ,
1557
+ )
1558
+ snapshot .match ("copy-object" , resp )
1559
+
1560
+ get_object_tags = aws_client .s3 .get_object_tagging (Bucket = s3_bucket , Key = object_key_copy )
1561
+ snapshot .match ("get-copy-object-tag" , get_object_tags )
1562
+
1563
+ object_key_copy_tag_empty = f"{ object_key } -copy-tag-empty"
1564
+ resp = aws_client .s3 .copy_object (
1565
+ Bucket = s3_bucket ,
1566
+ CopySource = f"{ s3_bucket } /{ object_key } " ,
1567
+ Key = object_key_copy_tag_empty ,
1568
+ ** kwargs ,
1569
+ )
1570
+ snapshot .match ("copy-object-tag-empty" , resp )
1571
+
1572
+ get_object_tags = aws_client .s3 .get_object_tagging (
1573
+ Bucket = s3_bucket , Key = object_key_copy_tag_empty
1574
+ )
1575
+ snapshot .match ("get-copy-object-tag-empty" , get_object_tags )
1576
+
1577
+ object_key_copy_v1 = f"{ object_key } -copy-v1"
1578
+ resp = aws_client .s3 .copy_object (
1579
+ Bucket = s3_bucket ,
1580
+ CopySource = f"{ s3_bucket } /{ object_key } ?versionId={ version_1 } " ,
1581
+ Key = object_key_copy_v1 ,
1582
+ Tagging = "key2=value2" ,
1583
+ ** kwargs ,
1584
+ )
1585
+ snapshot .match ("copy-object-v1" , resp )
1586
+
1587
+ get_object_tags = aws_client .s3 .get_object_tagging (Bucket = s3_bucket , Key = object_key_copy_v1 )
1588
+ snapshot .match ("get-copy-object-tag-v1" , get_object_tags )
1589
+
1590
+ object_key_copy_tag_empty_v1 = f"{ object_key } -copy-tag-empty-v1"
1591
+ resp = aws_client .s3 .copy_object (
1592
+ Bucket = s3_bucket ,
1593
+ CopySource = f"{ s3_bucket } /{ object_key } ?versionId={ version_1 } " ,
1594
+ Key = object_key_copy_tag_empty_v1 ,
1595
+ ** kwargs ,
1596
+ )
1597
+ snapshot .match ("copy-object-tag-empty-v1" , resp )
1598
+
1599
+ get_object_tags = aws_client .s3 .get_object_tagging (
1600
+ Bucket = s3_bucket , Key = object_key_copy_tag_empty_v1
1601
+ )
1602
+ snapshot .match ("get-copy-object-tag-empty-v1" , get_object_tags )
1603
+
1515
1604
@markers .aws .validated
1516
1605
@markers .snapshot .skip_snapshot_verify (
1517
1606
condition = is_v2_provider ,
0 commit comments