fix(s3): read the default encryption only from ApplyServerSideEncryptionByDefault (#9210)

This commit is contained in:
glorfindel33 authored and GitHub committed 2026-11-22 14:42:03 -04:00
1 parent 8183404fbd
commit dda3b96dee
2 files changed
+28 -10

No files matched your search

@@ -164,6 +164,23 @@ class S3DefaultEncryptionServiceTest {
s3Service.putBucketEncryption(BUCKET, "not xml");
assertEquals("AES256", put("malformed-configuration.txt", new PutObjectOptions()).getServerSideEncryption());
s3Service.putBucketEncryption(BUCKET, configuration("aws:kms", KMS_KEY) + "<Broken>");
assertEquals("AES256", put("truncated-configuration.txt", new PutObjectOptions()).getServerSideEncryption());
}
@Test
void aDefaultOutsideTheRuleIsIgnored() {
s3Service.putBucketEncryption(BUCKET, "<ServerSideEncryptionConfiguration>"
+ "<Elsewhere><SSEAlgorithm>AES256</SSEAlgorithm><KMSMasterKeyID>other-key</KMSMasterKeyID></Elsewhere>"
+ "<Rule><ApplyServerSideEncryptionByDefault><SSEAlgorithm>aws:kms</SSEAlgorithm>"
+ "<KMSMasterKeyID>" + KMS_KEY + "</KMSMasterKeyID></ApplyServerSideEncryptionByDefault></Rule>"
+ "</ServerSideEncryptionConfiguration>");
S3Object put = put("rule.txt", new PutObjectOptions());
assertEquals("aws:kms", put.getServerSideEncryption());
assertEquals(KMS_KEY, put.getSseKmsKeyId());
}
@Test